From 07e5bba4668cf4a78ac6b7e0f232c7e40b01beee Mon Sep 17 00:00:00 2001 From: Matthew Byng-Maddick Date: Fri, 19 Aug 2022 14:19:51 +0200 Subject: [PATCH 1/2] feat: allow webserver_config.py to come from the image Where you have a webserver_config.py that comes on the image you're using, there needs to be a way to turn it off Signed-off-by: Matthew Byng-Maddick --- .../airflow/templates/config/secret-webserver-config.yaml | 2 +- .../airflow/templates/webserver/webserver-deployment.yaml | 8 +++++++- charts/airflow/values.yaml | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/charts/airflow/templates/config/secret-webserver-config.yaml b/charts/airflow/templates/config/secret-webserver-config.yaml index c38952c835..7e90280d02 100644 --- a/charts/airflow/templates/config/secret-webserver-config.yaml +++ b/charts/airflow/templates/config/secret-webserver-config.yaml @@ -1,4 +1,4 @@ -{{- if not .Values.web.webserverConfig.existingSecret }} +{{- if (and .Values.web.webserverConfig.enabled (not .Values.web.webserverConfig.existingSecret)) }} apiVersion: v1 kind: Secret metadata: diff --git a/charts/airflow/templates/webserver/webserver-deployment.yaml b/charts/airflow/templates/webserver/webserver-deployment.yaml index 4e536dab7f..ddf469f883 100644 --- a/charts/airflow/templates/webserver/webserver-deployment.yaml +++ b/charts/airflow/templates/webserver/webserver-deployment.yaml @@ -42,7 +42,9 @@ spec: annotations: checksum/secret-config-envs: {{ include (print $.Template.BasePath "/config/secret-config-envs.yaml") . | sha256sum }} checksum/secret-local-settings: {{ include (print $.Template.BasePath "/config/secret-local-settings.yaml") . | sha256sum }} + {{- if .Values.web.webserverConfig.enabled }} checksum/config-webserver-config: {{ include (print $.Template.BasePath "/config/secret-webserver-config.yaml") . | sha256sum }} + {{- end }} {{- if .Values.airflow.podAnnotations }} {{- toYaml .Values.airflow.podAnnotations | nindent 8 }} {{- end }} @@ -136,10 +138,12 @@ spec: {{- end }} volumeMounts: {{- $volumeMounts | indent 12 }} + {{- if .Values.web.webserverConfig.enabled }} - name: webserver-config mountPath: /opt/airflow/webserver_config.py subPath: webserver_config.py readOnly: true + {{- end }} {{- if .Values.dags.gitSync.enabled }} {{- include "airflow.container.git_sync" . | indent 8 }} {{- end }} @@ -148,6 +152,7 @@ spec: {{- end }} volumes: {{- $volumes | indent 8 }} + {{- if .Values.web.webserverConfig.enabled }} - name: webserver-config secret: {{- if .Values.web.webserverConfig.existingSecret }} @@ -155,4 +160,5 @@ spec: {{- else }} secretName: {{ include "airflow.fullname" . }}-webserver-config {{- end }} - defaultMode: 0644 \ No newline at end of file + defaultMode: 0644 + {{- end }} diff --git a/charts/airflow/values.yaml b/charts/airflow/values.yaml index 9b7b987d96..c8381c6cd3 100644 --- a/charts/airflow/values.yaml +++ b/charts/airflow/values.yaml @@ -664,6 +664,10 @@ web: ######################################## ## webserverConfig: + ## by default, the helm chart owns the webserver config, however, sometimes it may be on a + ## custom version of the image. If this is the case, set this to false + enabled: true + ## the full content of the `webserver_config.py` file (as a string) ## - docs for Flask-AppBuilder security configs: ## https://flask-appbuilder.readthedocs.io/en/latest/security.html From d2809e93f0c8d464ad78b11d346fbebb4b869af6 Mon Sep 17 00:00:00 2001 From: Mathew Wicks Date: Wed, 5 Apr 2023 18:55:52 -0700 Subject: [PATCH 2/2] feat: allow disabling chart-managed `webserver_config.py` Signed-off-by: Mathew Wicks --- charts/airflow/docs/faq/configuration/airflow-configs.md | 4 ++++ charts/airflow/templates/config/secret-webserver-config.yaml | 2 +- charts/airflow/templates/webserver/webserver-deployment.yaml | 2 +- charts/airflow/values.yaml | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/charts/airflow/docs/faq/configuration/airflow-configs.md b/charts/airflow/docs/faq/configuration/airflow-configs.md index d23bc024f4..85ee6db9fb 100644 --- a/charts/airflow/docs/faq/configuration/airflow-configs.md +++ b/charts/airflow/docs/faq/configuration/airflow-configs.md @@ -74,6 +74,10 @@ web: ## the name of an existing Secret containing a `webserver_config.py` key ## NOTE: if set, takes precedence over `web.webserverConfig.stringOverride` #existingSecret: "my-airflow-webserver-config" + + ## if the `webserver_config.py` file is mounted + ## NOTE: set to false if you wish to mount your own `webserver_config.py` file + #enabled: false ``` > 🟦 __Tip__ 🟦 diff --git a/charts/airflow/templates/config/secret-webserver-config.yaml b/charts/airflow/templates/config/secret-webserver-config.yaml index 7e90280d02..c1aaa6b75d 100644 --- a/charts/airflow/templates/config/secret-webserver-config.yaml +++ b/charts/airflow/templates/config/secret-webserver-config.yaml @@ -1,4 +1,4 @@ -{{- if (and .Values.web.webserverConfig.enabled (not .Values.web.webserverConfig.existingSecret)) }} +{{- if and (.Values.web.webserverConfig.enabled) (not .Values.web.webserverConfig.existingSecret) }} apiVersion: v1 kind: Secret metadata: diff --git a/charts/airflow/templates/webserver/webserver-deployment.yaml b/charts/airflow/templates/webserver/webserver-deployment.yaml index ddf469f883..605b012cb3 100644 --- a/charts/airflow/templates/webserver/webserver-deployment.yaml +++ b/charts/airflow/templates/webserver/webserver-deployment.yaml @@ -42,7 +42,7 @@ spec: annotations: checksum/secret-config-envs: {{ include (print $.Template.BasePath "/config/secret-config-envs.yaml") . | sha256sum }} checksum/secret-local-settings: {{ include (print $.Template.BasePath "/config/secret-local-settings.yaml") . | sha256sum }} - {{- if .Values.web.webserverConfig.enabled }} + {{- if and (.Values.web.webserverConfig.enabled) (not .Values.web.webserverConfig.existingSecret) }} checksum/config-webserver-config: {{ include (print $.Template.BasePath "/config/secret-webserver-config.yaml") . | sha256sum }} {{- end }} {{- if .Values.airflow.podAnnotations }} diff --git a/charts/airflow/values.yaml b/charts/airflow/values.yaml index c8381c6cd3..de72da3001 100644 --- a/charts/airflow/values.yaml +++ b/charts/airflow/values.yaml @@ -664,8 +664,9 @@ web: ######################################## ## webserverConfig: - ## by default, the helm chart owns the webserver config, however, sometimes it may be on a - ## custom version of the image. If this is the case, set this to false + ## if the `webserver_config.py` file is mounted + ## - set to false if you wish to mount your own `webserver_config.py` file + ## enabled: true ## the full content of the `webserver_config.py` file (as a string)