diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml index d7b3c43079c16..947d95e9af6eb 100644 --- a/chart/templates/_helpers.yaml +++ b/chart/templates/_helpers.yaml @@ -997,3 +997,27 @@ capabilities: app: keda-operator {{- end }} {{- end }} + +{{- define "kubernetesVersion" -}} +{{ printf "%s" .Capabilities.KubeVersion.Version | trimPrefix "v" }} +{{- end -}} + +{{- define "airflowKerberosContainerArgs" -}} +{{- $kubectl_version := include "kubernetesVersion" . -}} +{{- if and (semverCompare ">=2.8.0" .Values.airflowVersion) (semverCompare "<1.28" $kubectl_version) }} +- airflow +- kerberos +- "&" +- while [ ! -f /opt/kerberos-exit/EXIT ]; do + if [ -f /opt/kerberos-exit/EXIT ]; then + echo "Exit lockfile found. Exiting kerberos process." + break + else + echo "Exit lockfile not found. Sleeping for 1 second..." + sleep 5 + fi + done +{{- else }} +- kerberos +{{- end }} +{{- end }} diff --git a/chart/templates/workers/worker-deployment.yaml b/chart/templates/workers/worker-deployment.yaml index 33fb357aae6d2..c2013496a9449 100644 --- a/chart/templates/workers/worker-deployment.yaml +++ b/chart/templates/workers/worker-deployment.yaml @@ -39,6 +39,7 @@ {{- $containerLifecycleHooksKerberosSidecar := or .Values.workers.kerberosSidecar.containerLifecycleHooks .Values.containerLifecycleHooks }} {{- $safeToEvict := dict "cluster-autoscaler.kubernetes.io/safe-to-evict" (.Values.workers.safeToEvict | toString) }} {{- $podAnnotations := mergeOverwrite .Values.airflowPodAnnotations $safeToEvict .Values.workers.podAnnotations }} +{{- $kubeVersion := include "kubernetesVersion" . }} apiVersion: apps/v1 kind: {{ if $persistence }}StatefulSet{{ else }}Deployment{{ end }} metadata: @@ -256,6 +257,10 @@ spec: - name: worker-logs containerPort: {{ .Values.ports.workerLogs }} volumeMounts: + {{- if and (semverCompare ">=2.8.0" .Values.airflowVersion) .Values.workers.kerberosSidecar.enabled (semverCompare "<1.28" $kubeVersion) }} + - name: kerberos-exit + mountPath: /opt/kerberos-exit + {{- end }} {{- if .Values.volumeMounts }} {{- toYaml .Values.volumeMounts | nindent 12 }} {{- end }} @@ -342,9 +347,13 @@ spec: {{- if $containerLifecycleHooksKerberosSidecar }} lifecycle: {{- tpl (toYaml $containerLifecycleHooksKerberosSidecar) . | nindent 12 }} {{- end }} - args: ["kerberos"] + args: {{ include "airflowKerberosContainerArgs" . | nindent 12 }} resources: {{- toYaml .Values.workers.kerberosSidecar.resources | nindent 12 }} volumeMounts: + {{- if and (semverCompare ">=2.8.0" .Values.airflowVersion) (semverCompare "<1.28" $kubeVersion) }} + - name: kerberos-exit + mountPath: /opt/kerberos-exit + {{- end }} - name: logs mountPath: {{ template "airflow_logs" . }} {{- include "airflow_config_mount" . | nindent 12 }} @@ -387,6 +396,10 @@ spec: {{- if .Values.workers.extraVolumes }} {{- tpl (toYaml .Values.workers.extraVolumes) . | nindent 8 }} {{- end }} + {{- if and (semverCompare ">=2.8.0" .Values.airflowVersion) .Values.workers.kerberosSidecar.enabled (semverCompare "<1.28" $kubeVersion) }} + - name: kerberos-exit + emptyDir: {} + {{- end }} - name: config configMap: name: {{ template "airflow_config" . }}