Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm chart fixes in pod template #11511

Merged
merged 2 commits into from
Oct 19, 2020
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
6 changes: 3 additions & 3 deletions chart/files/pod-template-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
spec:
{{- if .Values.dags.gitSync.enabled }}
initContainers:
{{- include "git_sync_container" . | indent 8 }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true") | indent 8 }}
{{- end }}
containers:
- args: []
Expand All @@ -32,7 +32,7 @@ spec:
value: LocalExecutor
{{- include "standard_airflow_environment" . | indent 4 }}
envFrom: []
image: dummy_image
image: {{ template "pod_template_image" . }}
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
name: base
ports: []
Expand All @@ -51,7 +51,7 @@ spec:
{{- end }}
{{- if or .Values.dags.gitSync.enabled .Values.dags.persistence.enabled }}
- mountPath: {{ include "airflow_dags_mount_path" . }}
name: airflow-dags
name: dags
readOnly: true
{{- if .Values.dags.persistence.enabled }}
subPath: {{.Values.dags.gitSync.dest }}/{{ .Values.dags.gitSync.subPath }}
Expand Down
8 changes: 8 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
value: {{ .Values.dags.gitSync.wait | quote }}
- name: GIT_SYNC_MAX_SYNC_FAILURES
value: {{ .Values.dags.gitSync.maxFailures | quote }}
{{- if .is_init }}
- name: GIT_SYNC_ONE_TIME
value: "true"
{{- end }}
volumeMounts:
- name: dags
mountPath: {{ .Values.dags.gitSync.root }}
Expand All @@ -174,6 +178,10 @@
{{ printf "%s:%s" (.Values.images.airflow.repository | default .Values.defaultAirflowRepository) (.Values.images.airflow.tag | default .Values.defaultAirflowTag) }}
{{- end }}

{{ define "pod_template_image" -}}
{{ printf "%s:%s" (.Values.images.pod_template.repository | default .Values.defaultAirflowRepository) (.Values.images.pod_template.tag | default .Values.defaultAirflowTag) }}
{{- end }}

# This helper is used for airflow containers that do not need the users code.
{{ define "default_airflow_image" -}}
{{ printf "%s:%s" .Values.defaultAirflowRepository .Values.defaultAirflowTag }}
Expand Down
20 changes: 18 additions & 2 deletions chart/tests/pod-template-file_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ tests:
asserts:
- isKind:
of: Pod
- equal:
- isNotNull:
path: spec.containers[0].image
value: dummy_image
Copy link
Contributor Author

@fllaca fllaca Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a way to assert that this value should be the default defaultAirflowRepository without hardcoding the test with apache/airflow:1.10.12 (copying from values.yaml). If that hardcoded value in the assertion is fine, I can change the test back to equal assert.

- equal:
path: spec.containers[0].name
value: base
Expand Down Expand Up @@ -77,6 +76,8 @@ tests:
value: "66"
- name: GIT_SYNC_MAX_SYNC_FAILURES
value: "70"
- name: GIT_SYNC_ONE_TIME
value: "true"
volumeMounts:
- mountPath: /git-root
name: dags
Expand Down Expand Up @@ -149,3 +150,18 @@ tests:
name: dags
persistentVolumeClaim:
claimName: test-claim
- it: should set a custom image in pod_template
set:
images:
pod_template:
repository: dummy_image
tag: latest
asserts:
- isKind:
of: Pod
- equal:
path: spec.containers[0].image
value: dummy_image:latest
- equal:
path: spec.containers[0].name
value: base
4 changes: 4 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ images:
repository: ~
tag: ~
pullPolicy: IfNotPresent
pod_template:
repository: ~
tag: ~
pullPolicy: IfNotPresent
flower:
repository: ~
tag: ~
Expand Down