Skip to content

Commit

Permalink
Handling exit of kerberos sidecar container for k8s < 1.28
Browse files Browse the repository at this point in the history
  • Loading branch information
amoghrajesh committed Nov 28, 2023
1 parent 44efd73 commit e831a5e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
24 changes: 24 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
15 changes: 14 additions & 1 deletion chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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" . }}
Expand Down

0 comments on commit e831a5e

Please sign in to comment.