Skip to content
Open
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 }}
15 changes: 5 additions & 10 deletions charts/questdb/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ 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 }}
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 @@ -50,14 +50,7 @@ spec:
{{- end }}
volumeMounts:
- name: {{ include "questdb.fullname" . }}
mountPath: {{ .Values.questdb.dataDir }}/db
subPath: db/
- name: {{ include "questdb.fullname" . }}
mountPath: {{ .Values.questdb.dataDir }}/.checkpoint
subPath: .checkpoint/
- name: {{ include "questdb.fullname" . }}
mountPath: {{ .Values.questdb.dataDir }}/snapshot
subPath: snapshot/
mountPath: {{ .Values.questdb.dataDir }}
{{- if .Values.questdb.serverConfig.enabled }}
- name: server-config
mountPath: {{ .Values.questdb.dataDir }}/conf/server.conf
Expand Down Expand Up @@ -103,6 +96,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 Down
23 changes: 21 additions & 2 deletions charts/questdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ nameOverride: ""
fullnameOverride: ""

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

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

extraVolumes: []
extraVolumeMounts: []
extraLabels: {}
Expand Down Expand Up @@ -121,3 +136,7 @@ dataMigration:
memory: "256Mi"
limits:
memory: "1Gi"

# openshift
openshift:
enabled: detect