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
9 changes: 8 additions & 1 deletion chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,14 @@ If release name contains chart name it will be used as a full name.
{{- end }}

{{- define "pod_template_image" -}}
{{- printf "%s:%s" (.Values.images.pod_template.repository | default .Values.defaultAirflowRepository) (.Values.images.pod_template.tag | default .Values.defaultAirflowTag) }}
{{- $repository := .Values.images.pod_template.repository | default .Values.defaultAirflowRepository -}}
{{- $tag := .Values.images.pod_template.tag | default .Values.defaultAirflowTag -}}
{{- $digest := .Values.images.pod_template.digest | default .Values.defaultAirflowDigest -}}
{{- if $digest }}
{{- printf "%s@%s" $repository $digest -}}
{{- else }}
{{- printf "%s:%s" $repository $tag -}}
{{- end }}
{{- end }}

{{/* This helper is used for airflow containers that do not need the users code */}}
Expand Down
8 changes: 8 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,14 @@
],
"default": null
},
"digest": {
"description": "The pod_template image digest. If set, it will override the tag. If ``config.kubernetes_executor.worker_container_repository`` and ``config.kubernetes_executor.worker_container_tag`` are set, the k8s executor will use those instead.",
"type": [
"string",
"null"
],
"default": null
},
"pullPolicy": {
"description": "The pod_template image pull policy.",
"type": "string",
Expand Down
8 changes: 5 additions & 3 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ images:
# timeout (in seconds) for airflow-migrations to complete
migrationsWaitTimeout: 60
pod_template:
# Note that `images.pod_template.repository` and `images.pod_template.tag` parameters can be overridden
# in `config.kubernetes_executor` section. So for these parameters to have effect
# `config.kubernetes_executor.worker_container_repository` and
# Note that `images.pod_template.repository`, `images.pod_template.tag` and `images.pod_template.digest`
# parameters can be overridden in `config.kubernetes_executor` section. So for these parameters
# to have effect `config.kubernetes_executor.worker_container_repository` and
# `config.kubernetes_executor.worker_container_tag` must be not set .
repository: ~
tag: ~
# Specifying digest takes precedence over tag.
digest: ~
pullPolicy: IfNotPresent
flower:
repository: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,39 @@ def test_should_set_a_custom_image_in_pod_template(self):
assert jmespath.search("spec.containers[0].imagePullPolicy", docs[0]) == "Always"
assert jmespath.search("spec.containers[0].name", docs[0]) == "base"

@pytest.mark.parametrize(
("expected_image", "tag", "digest"),
[
("dummy_image:user-tag", "user-tag", None),
("dummy_image@user-digest", None, "user-digest"),
("dummy_image@user-digest", "user-tag", "user-digest"),
],
)
def test_should_use_correct_pod_template_image(self, expected_image, tag, digest):
docs = render_chart(
values={
"images": {
"pod_template": {"repository": "dummy_image", "tag": tag, "digest": digest},
},
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert jmespath.search("spec.containers[0].image", docs[0]) == expected_image

def test_should_use_default_airflow_digest_in_pod_template(self):
docs = render_chart(
values={
"defaultAirflowRepository": "test-repo",
"defaultAirflowDigest": "user-digest",
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert jmespath.search("spec.containers[0].image", docs[0]) == "test-repo@user-digest"

def test_mount_airflow_cfg(self):
docs = render_chart(
values={},
Expand Down
Loading