Skip to content

Commit

Permalink
feat: add airflow.defaultContainerSecurityContext value (#624)
Browse files Browse the repository at this point in the history
* feat: add defaultContainerSecurityContext

Signed-off-by: Philipp Hitzler <[email protected]>

* fix ct lint

Signed-off-by: Philipp Hitzler <[email protected]>

* chore: small cleanups

Signed-off-by: Mathew Wicks <[email protected]>

---------

Signed-off-by: Philipp Hitzler <[email protected]>
Signed-off-by: Mathew Wicks <[email protected]>
Co-authored-by: Mathew Wicks <[email protected]>
  • Loading branch information
zartstrom and thesuperzapper authored May 1, 2024
1 parent a9513df commit 3b778fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions charts/airflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Parameter | Description | Default
`airflow.defaultTolerations` | default toleration configs for airflow Pods (is overridden by pod-specific values) | `[]`
`airflow.defaultTopologySpreadConstraints` | default topologySpreadConstraints for airflow Pods (is overridden by pod-specific values) | `[]`
`airflow.defaultSecurityContext` | default securityContext configs for Pods (is overridden by pod-specific values) | `{fsGroup: 0}`
`airflow.defaultContainerSecurityContext` | default securityContext for Containers in airflow Pods | `{}`
`airflow.podAnnotations` | extra annotations for airflow Pods | `{}`
`airflow.extraPipPackages` | extra pip packages to install in airflow Pods | `[]`
`airflow.protectedPipPackages` | pip packages that are protected from upgrade/downgrade by `extraPipPackages` | `["apache-airflow"]`
Expand Down
6 changes: 6 additions & 0 deletions charts/airflow/templates/_helpers/pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ imagePullPolicy: {{ .Values.airflow.image.pullPolicy }}
securityContext:
runAsUser: {{ .Values.airflow.image.uid }}
runAsGroup: {{ .Values.airflow.image.gid }}
{{- if .Values.airflow.defaultContainerSecurityContext }}
{{- omit .Values.airflow.defaultContainerSecurityContext "runAsUser" "runAsGroup" | toYaml | nindent 2 }}
{{- end }}
{{- end }}

{{/*
Expand Down Expand Up @@ -207,6 +210,9 @@ EXAMPLE USAGE: {{ include "airflow.container.git_sync" (dict "Release" .Release
securityContext:
runAsUser: {{ .Values.dags.gitSync.image.uid }}
runAsGroup: {{ .Values.dags.gitSync.image.gid }}
{{- if .Values.airflow.defaultContainerSecurityContext }}
{{- omit .Values.airflow.defaultContainerSecurityContext "runAsUser" "runAsGroup" | toYaml | nindent 4 }}
{{- end }}
resources:
{{- toYaml .Values.dags.gitSync.resources | nindent 4 }}
envFrom:
Expand Down
3 changes: 3 additions & 0 deletions charts/airflow/templates/pgbouncer/pgbouncer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ spec:
securityContext:
runAsUser: {{ .Values.pgbouncer.image.uid }}
runAsGroup: {{ .Values.pgbouncer.image.gid }}
{{- if .Values.airflow.defaultContainerSecurityContext }}
{{- omit .Values.airflow.defaultContainerSecurityContext "runAsUser" "runAsGroup" | toYaml | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.pgbouncer.resources | nindent 12 }}
envFrom:
Expand Down
10 changes: 9 additions & 1 deletion charts/airflow/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ airflow:
## this does NOT give root permissions to Pods, only the "root" group
fsGroup: 0

## default securityContext for Containers in airflow Pods
## - spec for SecurityContext:
## https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#securitycontext-v1-core
## - `runAsUser` is ignored, please set with per-image `*.image.uid`
## - `runAsGroup` is ignored, please set with per-image `*.image.gid`
##
defaultContainerSecurityContext: {}

## extra annotations for airflow Pods
##
podAnnotations: {}
Expand Down Expand Up @@ -2183,7 +2191,7 @@ redis:
## the access mode of the PVC
##
accessModes:
- ReadWriteOnce
- ReadWriteOnce

## the size of PVC to request
##
Expand Down

0 comments on commit 3b778fc

Please sign in to comment.