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
2 changes: 1 addition & 1 deletion chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ spec:
terminationGracePeriodSeconds: {{ .Values.workers.kubernetes.terminationGracePeriodSeconds | default .Values.workers.terminationGracePeriodSeconds }}
tolerations: {{- toYaml $tolerations | nindent 4 }}
topologySpreadConstraints: {{- toYaml $topologySpreadConstraints | nindent 4 }}
{{- if .Values.workers.kubernetes.serviceAccount.create }}
{{- if has .Values.workers.kubernetes.serviceAccount.create (list true false) }}
serviceAccountName: {{ include "worker.kubernetes.serviceAccountName" . }}
{{- else }}
serviceAccountName: {{ include "worker.serviceAccountName" . }}
Expand Down
3 changes: 2 additions & 1 deletion chart/templates/workers/worker-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
{{- $workers := (include "workersMergeValues" (list $mergedWorkers $workerSet "" list) | fromYaml) -}}
{{- $_ := set $globals.Values "workers" $workers -}}
{{- with $globals -}}
{{- if and .Values.workers.serviceAccount.create (include "airflow.podLaunchingExecutor" .) }}
{{- $useKubernetesServiceAccount := and (contains "KubernetesExecutor" .Values.executor) (has .Values.workers.kubernetes.serviceAccount.create (list true false)) -}}
{{- if and .Values.workers.serviceAccount.create (include "airflow.podLaunchingExecutor" .) (or (contains "CeleryExecutor" .Values.executor) (not $useKubernetesServiceAccount)) }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2127,3 +2127,22 @@ def test_dedicated_service_account_name_default(self):
)

assert jmespath.search("spec.serviceAccountName", docs[0]) == "test-release-airflow-worker-kubernetes"

def test_dedicated_service_account_name_when_creation_disabled(self):
docs = render_chart(
name="test-release",
values={
"workers": {
"kubernetes": {
"serviceAccount": {
"create": False,
"name": "airflow",
}
}
}
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert jmespath.search("spec.serviceAccountName", docs[0]) == "airflow"
18 changes: 18 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,24 @@ def test_should_create_service_account_when_enabled(self):

assert len(docs) == 1

def test_should_not_create_legacy_service_account_when_k8s_service_account_disabled(self):
docs = render_chart(
values={
"executor": "KubernetesExecutor",
"workers": {
"kubernetes": {
"serviceAccount": {
"create": False,
"name": "airflow",
}
}
},
},
show_only=["templates/workers/worker-serviceaccount.yaml"],
)

assert len(docs) == 0

@pytest.mark.parametrize(
"executor",
[
Expand Down