Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions charts/questdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,45 @@ Generate log.conf file content
{{ $key }} = {{ $value }}
{{- end }}
{{- end }}

{{/*
Build openshift detection
*/}}
{{- define "isOpenshiftEnabled" -}}
{{- $openshiftEnabledString := (.Values.openshift).enabled | toString -}}
{{- if eq $openshiftEnabledString "true" -}}
true
{{- else if and (eq $openshiftEnabledString "detect") (.Capabilities.APIVersions.Has "security.openshift.io/v1") }}
true
{{- end }}
{{- end }}

{{/*
Build securityContext
*/}}
{{- define "generateSecurityContext" -}}
{{- $context := .Values.securityContext -}}
{{- if $context -}}
{{- if (include "isOpenshiftEnabled" .) -}}
{{- $context = omit $context "runAsUser" "runAsGroup" "fsGroup" -}}
{{- end -}}
{{- else -}}
{{ $context = dict -}}
{{- end -}}
{{ $context | toYaml }}
{{- end }}

{{/*
Build podSecurityContext
*/}}
{{- define "generatePodSecurityContext" -}}
{{- $context := .Values.podSecurityContext -}}
{{- if $context -}}
{{- if (include "isOpenshiftEnabled" .) -}}
{{- $context = omit $context "runAsUser" "runAsGroup" "fsGroup" -}}
{{- end -}}
{{- else -}}
{{ $context = dict -}}
{{- end -}}
{{ $context | toYaml }}
{{- end }}
1 change: 1 addition & 0 deletions charts/questdb/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
metadata:
name: {{ include "questdb.serviceAccountName" . }}
{{- if .Values.serviceAccount.labels }}
Expand Down
15 changes: 13 additions & 2 deletions charts/questdb/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- include "generatePodSecurityContext" . | nindent 8 }}
{{- if or .Values.serviceAccount.create .Values.serviceAccount.name }}
serviceAccountName: {{ include "questdb.serviceAccountName" . }}
{{- end }}
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- include "generateSecurityContext" . | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand All @@ -49,6 +50,10 @@ spec:
{{ toYaml .Values.questdb.envFrom | nindent 10 }}
{{- end }}
volumeMounts:
- name: tmpfs-tmp
mountPath: /tmp
- name: tmpfs-questdb
mountPath: /var/lib/questdb
- name: {{ include "questdb.fullname" . }}
mountPath: {{ .Values.questdb.dataDir }}/db
subPath: db/
Expand Down Expand Up @@ -103,6 +108,8 @@ spec:
- name: init-db-migration
image: "{{ .Values.dataMigration.image.repository }}:{{ .Values.dataMigration.image.tag }}"
command: ["bash", "/mnt/migration_scripts/migrate_to_helm_v1.sh"]
securityContext:
{{- include "generateSecurityContext" . | nindent 12 }}
volumeMounts:
- name: {{ include "questdb.fullname" . }}
mountPath: /mnt/questdb
Expand All @@ -128,6 +135,10 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: tmpfs-tmp
emptyDir: {}
- name: tmpfs-questdb
emptyDir: {}
{{- if .Values.questdb.serverConfig.enabled }}
- name: server-config
{{- if eq .Values.questdb.configStorageType "Secret" }}
Expand Down
27 changes: 25 additions & 2 deletions charts/questdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@ nameOverride: ""
fullnameOverride: ""

podAnnotations: {}
podSecurityContext: {}
securityContext: {}
podSecurityContext:
fsGroup: 10001
seccompProfile:
type: RuntimeDefault

securityContext:
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault

extraVolumes: []
extraVolumeMounts: []
extraLabels: {}
Expand Down Expand Up @@ -94,6 +110,7 @@ livenessProbe: {}
# successThreshold: 1
# timeoutSeconds: 2

automountServiceAccountToken: false

metrics:
enabled: true
Expand All @@ -106,6 +123,7 @@ serviceAccount:
create: false
labels: {}
annotations: {}
automountServiceAccountToken: false

# if create is set to "true", you can specify the name of that service account below
# if create is set to "false", you can use this to reference an existing service account for the StatefulSet pod
Expand All @@ -121,3 +139,8 @@ dataMigration:
memory: "256Mi"
limits:
memory: "1Gi"

# openshift
openshift:
enabled: detect