This is an automated email from the ASF dual-hosted git repository. jedcunningham pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 20a1c4db98 Add global volume & volumeMounts to the chart (#27781) 20a1c4db98 is described below commit 20a1c4db9882a223ae08de1a46e9bdf993698865 Author: Carlos Sánchez Páez <carlos.sanc...@feverup.com> AuthorDate: Fri Dec 9 20:07:48 2022 +0100 Add global volume & volumeMounts to the chart (#27781) --- .../dag-processor/dag-processor-deployment.yaml | 6 +++++ chart/templates/flower/flower-deployment.yaml | 6 +++++ chart/templates/jobs/create-user-job.yaml | 6 +++++ chart/templates/jobs/migrate-database-job.yaml | 6 +++++ .../templates/pgbouncer/pgbouncer-deployment.yaml | 6 +++++ .../templates/scheduler/scheduler-deployment.yaml | 12 +++++++++ .../templates/triggerer/triggerer-deployment.yaml | 9 +++++++ .../templates/webserver/webserver-deployment.yaml | 9 +++++++ chart/templates/workers/worker-deployment.yaml | 15 +++++++++++ chart/values.schema.json | 18 +++++++++++++ chart/values.yaml | 6 +++++ tests/charts/test_create_user_job.py | 16 ++++++++++++ tests/charts/test_dag_processor.py | 15 +++++++++++ tests/charts/test_flower.py | 17 ++++++++++++ tests/charts/test_migrate_database_job.py | 16 ++++++++++++ tests/charts/test_pgbouncer.py | 26 +++++++++++++++++++ tests/charts/test_scheduler.py | 14 ++++++++++ tests/charts/test_triggerer.py | 14 ++++++++++ tests/charts/test_webserver.py | 30 ++++++++++++++++++++++ tests/charts/test_worker.py | 14 ++++++++++ 20 files changed, 261 insertions(+) diff --git a/chart/templates/dag-processor/dag-processor-deployment.yaml b/chart/templates/dag-processor/dag-processor-deployment.yaml index fef28af5aa..96abd3ff2b 100644 --- a/chart/templates/dag-processor/dag-processor-deployment.yaml +++ b/chart/templates/dag-processor/dag-processor-deployment.yaml @@ -147,6 +147,9 @@ spec: resources: {{ toYaml .Values.dagProcessor.resources | nindent 12 }} volumeMounts: + {{- if .Values.volumeMounts }} + {{ toYaml .Values.volumeMounts | nindent 12 }} + {{- end }} {{- if .Values.dagProcessor.extraVolumeMounts }} {{ toYaml .Values.dagProcessor.extraVolumeMounts | nindent 12 }} {{- end }} @@ -195,6 +198,9 @@ spec: {{- if and .Values.dags.gitSync.enabled .Values.dags.gitSync.sshKeySecret }} {{- include "git_sync_ssh_key_volume" . | indent 8 }} {{- end }} + {{- if .Values.volumes }} + {{- toYaml .Values.volumes | nindent 8 }} + {{- end }} {{- if .Values.dagProcessor.extraVolumes }} {{- toYaml .Values.dagProcessor.extraVolumes | nindent 8 }} {{- end }} diff --git a/chart/templates/flower/flower-deployment.yaml b/chart/templates/flower/flower-deployment.yaml index ca39b369d4..5c92193502 100644 --- a/chart/templates/flower/flower-deployment.yaml +++ b/chart/templates/flower/flower-deployment.yaml @@ -97,6 +97,9 @@ spec: {{ toYaml .Values.flower.resources | indent 12 }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} + {{- if .Values.volumeMounts }} + {{ toYaml .Values.volumeMounts | nindent 12 }} + {{- end }} {{- if .Values.flower.extraVolumeMounts }} {{ toYaml .Values.flower.extraVolumeMounts | nindent 12 }} {{- end }} @@ -147,6 +150,9 @@ spec: - name: config configMap: name: {{ template "airflow_config" . }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.flower.extraVolumes }} {{ toYaml .Values.flower.extraVolumes | indent 8 }} {{- end }} diff --git a/chart/templates/jobs/create-user-job.yaml b/chart/templates/jobs/create-user-job.yaml index 784ae05262..a4bb2bde9f 100644 --- a/chart/templates/jobs/create-user-job.yaml +++ b/chart/templates/jobs/create-user-job.yaml @@ -106,6 +106,9 @@ spec: {{ toYaml .Values.createUserJob.resources | indent 12 }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.createUserJob.extraVolumeMounts }} {{ toYaml .Values.createUserJob.extraVolumeMounts | nindent 12 }} {{- end }} @@ -116,6 +119,9 @@ spec: - name: config configMap: name: {{ template "airflow_config" . }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.createUserJob.extraVolumes }} {{ toYaml .Values.createUserJob.extraVolumes | nindent 8 }} {{- end }} diff --git a/chart/templates/jobs/migrate-database-job.yaml b/chart/templates/jobs/migrate-database-job.yaml index 5669fe2d40..67e61abf48 100644 --- a/chart/templates/jobs/migrate-database-job.yaml +++ b/chart/templates/jobs/migrate-database-job.yaml @@ -107,6 +107,9 @@ spec: {{ toYaml .Values.migrateDatabaseJob.resources | indent 12 }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.migrateDatabaseJob.extraVolumeMounts }} {{ toYaml .Values.migrateDatabaseJob.extraVolumeMounts | nindent 12 }} {{- end }} @@ -117,6 +120,9 @@ spec: - name: config configMap: name: {{ template "airflow_config" . }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.migrateDatabaseJob.extraVolumes }} {{ toYaml .Values.migrateDatabaseJob.extraVolumes | nindent 8 }} {{- end }} diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml b/chart/templates/pgbouncer/pgbouncer-deployment.yaml index f2e31cb029..3d5f76c81c 100644 --- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml +++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml @@ -131,6 +131,9 @@ spec: mountPath: /etc/pgbouncer/server.key readOnly: true {{- end }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.pgbouncer.extraVolumeMounts }} {{ toYaml .Values.pgbouncer.extraVolumeMounts | indent 12 }} {{- end }} @@ -176,6 +179,9 @@ spec: secret: secretName: {{ template "pgbouncer_certificates_secret" . }} {{- end }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.pgbouncer.extraVolumes }} {{ toYaml .Values.pgbouncer.extraVolumes | indent 8 }} {{- end }} diff --git a/chart/templates/scheduler/scheduler-deployment.yaml b/chart/templates/scheduler/scheduler-deployment.yaml index 9f8411c716..94cd7fd95a 100644 --- a/chart/templates/scheduler/scheduler-deployment.yaml +++ b/chart/templates/scheduler/scheduler-deployment.yaml @@ -137,6 +137,9 @@ spec: imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.scheduler.extraVolumeMounts }} {{ toYaml .Values.scheduler.extraVolumeMounts | indent 12 }} {{- end }} @@ -213,6 +216,9 @@ spec: {{- if and $localOrDagProcessorDisabled (or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled) }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.scheduler.extraVolumeMounts }} {{ toYaml .Values.scheduler.extraVolumeMounts | indent 12 }} {{- end }} @@ -239,6 +245,9 @@ spec: volumeMounts: - name: logs mountPath: {{ template "airflow_logs" . }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.scheduler.extraVolumeMounts }} {{ toYaml .Values.scheduler.extraVolumeMounts | indent 12 }} {{- end }} @@ -271,6 +280,9 @@ spec: {{- end }} {{- end}} {{- end }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.scheduler.extraVolumes }} {{ toYaml .Values.scheduler.extraVolumes | indent 8 }} {{- end }} diff --git a/chart/templates/triggerer/triggerer-deployment.yaml b/chart/templates/triggerer/triggerer-deployment.yaml index 33f478caed..befee9c90a 100644 --- a/chart/templates/triggerer/triggerer-deployment.yaml +++ b/chart/templates/triggerer/triggerer-deployment.yaml @@ -117,6 +117,9 @@ spec: imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} + {{- if .Values.volumeMounts }} + {{ toYaml .Values.volumeMounts | nindent 12 }} + {{- end }} {{- if .Values.triggerer.extraVolumeMounts }} {{ toYaml .Values.triggerer.extraVolumeMounts | nindent 12 }} {{- end }} @@ -153,6 +156,9 @@ spec: resources: {{ toYaml .Values.triggerer.resources | nindent 12 }} volumeMounts: + {{- if .Values.volumeMounts }} + {{ toYaml .Values.volumeMounts | nindent 12 }} + {{- end }} {{- if .Values.triggerer.extraVolumeMounts }} {{ toYaml .Values.triggerer.extraVolumeMounts | nindent 12 }} {{- end }} @@ -209,6 +215,9 @@ spec: {{- include "git_sync_ssh_key_volume" . | indent 8 }} {{- end }} {{- end }} + {{- if .Values.volumes }} + {{- toYaml .Values.volumes | nindent 8 }} + {{- end }} {{- if .Values.triggerer.extraVolumes }} {{- toYaml .Values.triggerer.extraVolumes | nindent 8 }} {{- end }} diff --git a/chart/templates/webserver/webserver-deployment.yaml b/chart/templates/webserver/webserver-deployment.yaml index 81d97ab83d..bfc83a2140 100644 --- a/chart/templates/webserver/webserver-deployment.yaml +++ b/chart/templates/webserver/webserver-deployment.yaml @@ -129,6 +129,9 @@ spec: imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.webserver.extraVolumeMounts }} {{ toYaml .Values.webserver.extraVolumeMounts | indent 12 }} {{- end }} @@ -182,6 +185,9 @@ spec: - name: logs mountPath: {{ template "airflow_logs" . }} {{- end }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.webserver.extraVolumeMounts }} {{ toYaml .Values.webserver.extraVolumeMounts | indent 12 }} {{- end }} @@ -255,6 +261,9 @@ spec: persistentVolumeClaim: claimName: {{ template "airflow_logs_volume_claim" . }} {{- end }} +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.webserver.extraVolumes }} {{ toYaml .Values.webserver.extraVolumes | indent 8 }} {{- end }} diff --git a/chart/templates/workers/worker-deployment.yaml b/chart/templates/workers/worker-deployment.yaml index 5e8969b669..2c221e7f88 100644 --- a/chart/templates/workers/worker-deployment.yaml +++ b/chart/templates/workers/worker-deployment.yaml @@ -147,6 +147,9 @@ spec: imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: {{- include "airflow_config_mount" . | nindent 12 }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.workers.extraVolumeMounts }} {{ toYaml .Values.workers.extraVolumeMounts | indent 12 }} {{- end }} @@ -201,6 +204,9 @@ spec: - name: worker-logs containerPort: {{ .Values.ports.workerLogs }} volumeMounts: +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.workers.extraVolumeMounts }} {{ toYaml .Values.workers.extraVolumeMounts | indent 12 }} {{- end }} @@ -260,6 +266,9 @@ spec: volumeMounts: - name: logs mountPath: {{ template "airflow_logs" . }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.workers.extraVolumeMounts }} {{ toYaml .Values.workers.extraVolumeMounts | indent 12 }} {{- end }} @@ -289,6 +298,9 @@ spec: - name: kerberos-ccache mountPath: {{ .Values.kerberos.ccacheMountPath | quote }} readOnly: false +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | nindent 12 }} +{{- end }} {{- if .Values.workers.extraVolumeMounts }} {{ toYaml .Values.workers.extraVolumeMounts | indent 12 }} {{- end }} @@ -309,6 +321,9 @@ spec: {{- toYaml .Values.workers.extraContainers | nindent 8 }} {{- end }} volumes: +{{- if .Values.volumes }} +{{- toYaml .Values.volumes | nindent 8 }} +{{- end }} {{- if .Values.workers.extraVolumes }} {{ toYaml .Values.workers.extraVolumes | indent 8 }} {{- end }} diff --git a/chart/values.schema.json b/chart/values.schema.json index 96506e24c4..44f87ddf43 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -724,6 +724,24 @@ } ] }, + "volumes": { + "description": "Volumes for all Airflow containers.", + "x-docsSection": "Airflow", + "type": "array", + "default": [], + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Volume" + } + }, + "volumeMounts": { + "description": "VolumeMounts for all Airflow containers.", + "x-docsSection": "Airflow", + "type": "array", + "default": [], + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.VolumeMount" + } + }, "secret": { "description": "Secrets for all Airflow containers.", "type": "array", diff --git a/chart/values.yaml b/chart/values.yaml index 22bba7da14..f22980c94c 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -243,6 +243,12 @@ env: [] # - name: "" # value: "" +# Volumes for all airflow containers +volumes: [] + +# VolumeMounts for all airflow containers +volumeMounts: [] + # Secrets for all airflow containers secret: [] # - envName: "" diff --git a/tests/charts/test_create_user_job.py b/tests/charts/test_create_user_job.py index 74c0fa9f44..92fe5e22ce 100644 --- a/tests/charts/test_create_user_job.py +++ b/tests/charts/test_create_user_job.py @@ -181,6 +181,22 @@ class TestCreateUserJob: "spec.template.spec.containers[0].volumeMounts[-1]", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "myvolume", "emptyDir": {}}], + "volumeMounts": [{"name": "foobar", "mountPath": "foo/bar"}], + }, + show_only=["templates/jobs/create-user-job.yaml"], + ) + + assert {"name": "myvolume", "emptyDir": {}} == jmespath.search( + "spec.template.spec.volumes[-1]", docs[0] + ) + assert {"name": "foobar", "mountPath": "foo/bar"} == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[-1]", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={ diff --git a/tests/charts/test_dag_processor.py b/tests/charts/test_dag_processor.py index 1e84480cd5..8d3bef7346 100644 --- a/tests/charts/test_dag_processor.py +++ b/tests/charts/test_dag_processor.py @@ -119,6 +119,21 @@ class TestDagProcessor: "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "dagProcessor": {"enabled": True}, + "volumes": [{"name": "test-volume", "emptyDir": {}}], + "volumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + show_only=["templates/dag-processor/dag-processor-deployment.yaml"], + ) + + assert "test-volume" == jmespath.search("spec.template.spec.volumes[1].name", docs[0]) + assert "test-volume" == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={ diff --git a/tests/charts/test_flower.py b/tests/charts/test_flower.py index 47e560a330..81cb3fe02a 100644 --- a/tests/charts/test_flower.py +++ b/tests/charts/test_flower.py @@ -268,6 +268,23 @@ class TestFlowerDeployment: "spec.template.spec.containers[0].volumeMounts", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "flower": { + "enabled": True, + }, + "volumes": [{"name": "myvolume", "emptyDir": {}}], + "volumeMounts": [{"name": "myvolume", "mountPath": "/opt/test"}], + }, + show_only=["templates/flower/flower-deployment.yaml"], + ) + + assert {"name": "myvolume", "emptyDir": {}} in jmespath.search("spec.template.spec.volumes", docs[0]) + assert {"name": "myvolume", "mountPath": "/opt/test"} in jmespath.search( + "spec.template.spec.containers[0].volumeMounts", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={ diff --git a/tests/charts/test_migrate_database_job.py b/tests/charts/test_migrate_database_job.py index 9155954f60..d25fdbb4b8 100644 --- a/tests/charts/test_migrate_database_job.py +++ b/tests/charts/test_migrate_database_job.py @@ -219,6 +219,22 @@ class TestMigrateDatabaseJob: "spec.template.spec.containers[0].volumeMounts[-1]", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "myvolume", "emptyDir": {}}], + "volumeMounts": [{"name": "foobar", "mountPath": "foo/bar"}], + }, + show_only=["templates/jobs/migrate-database-job.yaml"], + ) + + assert {"name": "myvolume", "emptyDir": {}} == jmespath.search( + "spec.template.spec.volumes[-1]", docs[0] + ) + assert {"name": "foobar", "mountPath": "foo/bar"} == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[-1]", docs[0] + ) + @pytest.mark.parametrize( "airflow_version, expected_arg", [ diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index f57d982902..35981f1a7d 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -307,6 +307,32 @@ class TestPgbouncer: "spec.template.spec.containers[0].volumeMounts[*].name", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "pgbouncer": { + "enabled": True, + }, + "volumes": [ + { + "name": "pgbouncer-client-certificates", + "secret": {"secretName": "pgbouncer-client-tls-certificate"}, + } + ], + "volumeMounts": [ + {"name": "pgbouncer-client-certificates", "mountPath": "/etc/pgbouncer/certs"} + ], + }, + show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"], + ) + + assert "pgbouncer-client-certificates" in jmespath.search( + "spec.template.spec.volumes[*].name", docs[0] + ) + assert "pgbouncer-client-certificates" in jmespath.search( + "spec.template.spec.containers[0].volumeMounts[*].name", docs[0] + ) + def test_pgbouncer_replicas_are_configurable(self): docs = render_chart( values={ diff --git a/tests/charts/test_scheduler.py b/tests/charts/test_scheduler.py index 3c456b862c..fe98861fda 100644 --- a/tests/charts/test_scheduler.py +++ b/tests/charts/test_scheduler.py @@ -115,6 +115,20 @@ class TestScheduler: "spec.template.spec.containers[0].volumeMounts[*].name", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "test-volume", "emptyDir": {}}], + "volumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + show_only=["templates/scheduler/scheduler-deployment.yaml"], + ) + + assert "test-volume" in jmespath.search("spec.template.spec.volumes[*].name", docs[0]) + assert "test-volume" in jmespath.search( + "spec.template.spec.containers[0].volumeMounts[*].name", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={ diff --git a/tests/charts/test_triggerer.py b/tests/charts/test_triggerer.py index 5921d4e4ec..757bdb4fa4 100644 --- a/tests/charts/test_triggerer.py +++ b/tests/charts/test_triggerer.py @@ -134,6 +134,20 @@ class TestTriggerer: "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "test-volume", "emptyDir": {}}], + "volumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + show_only=["templates/triggerer/triggerer-deployment.yaml"], + ) + + assert "test-volume" == jmespath.search("spec.template.spec.volumes[1].name", docs[0]) + assert "test-volume" == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={ diff --git a/tests/charts/test_webserver.py b/tests/charts/test_webserver.py index c5551e730b..5de32e90a8 100644 --- a/tests/charts/test_webserver.py +++ b/tests/charts/test_webserver.py @@ -180,6 +180,36 @@ class TestWebserverDeployment: "spec.template.spec.containers[0].env", docs[0] ) + def test_should_add_extra_volume_and_extra_volume_mount(self): + docs = render_chart( + values={ + "webserver": { + "extraVolumes": [{"name": "test-volume", "emptyDir": {}}], + "extraVolumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + }, + show_only=["templates/webserver/webserver-deployment.yaml"], + ) + + assert "test-volume" == jmespath.search("spec.template.spec.volumes[-1].name", docs[0]) + assert "test-volume" == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[-1].name", docs[0] + ) + + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "test-volume", "emptyDir": {}}], + "volumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + show_only=["templates/webserver/webserver-deployment.yaml"], + ) + + assert "test-volume" == jmespath.search("spec.template.spec.volumes[-1].name", docs[0]) + assert "test-volume" == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[-1].name", docs[0] + ) + def test_should_add_extraEnvs_to_wait_for_migration_container(self): docs = render_chart( values={ diff --git a/tests/charts/test_worker.py b/tests/charts/test_worker.py index 1838727072..7056e5b815 100644 --- a/tests/charts/test_worker.py +++ b/tests/charts/test_worker.py @@ -115,6 +115,20 @@ class TestWorker: "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] ) + def test_should_add_global_volume_and_global_volume_mount(self): + docs = render_chart( + values={ + "volumes": [{"name": "test-volume", "emptyDir": {}}], + "volumeMounts": [{"name": "test-volume", "mountPath": "/opt/test"}], + }, + show_only=["templates/workers/worker-deployment.yaml"], + ) + + assert "test-volume" == jmespath.search("spec.template.spec.volumes[0].name", docs[0]) + assert "test-volume" == jmespath.search( + "spec.template.spec.containers[0].volumeMounts[0].name", docs[0] + ) + def test_should_add_extraEnvs(self): docs = render_chart( values={