From b3995ee6af6308502b4292ea30e00488bab4cf6c Mon Sep 17 00:00:00 2001 From: Jesse Bye <8467862+jessebye@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:48:24 -0700 Subject: [PATCH] fix: template extraEnv Signed-off-by: Jesse Bye <8467862+jessebye@users.noreply.github.com> Signed-off-by: jessebye <8467862+jessebye@users.noreply.github.com> --- charts/airflow/README.md | 2 +- .../airflow/docs/faq/configuration/airflow-configs.md | 4 +++- .../faq/kubernetes/mount-environment-variables.md | 11 ++++++++++- charts/airflow/templates/_helpers/pods.tpl | 2 +- charts/airflow/values.yaml | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/charts/airflow/README.md b/charts/airflow/README.md index ad8d3c92..bed87644 100644 --- a/charts/airflow/README.md +++ b/charts/airflow/README.md @@ -224,7 +224,7 @@ Parameter | Description | Default `airflow.podAnnotations` | extra annotations for airflow Pods | `{}` `airflow.extraPipPackages` | extra pip packages to install in airflow Pods | `[]` `airflow.protectedPipPackages` | pip packages that are protected from upgrade/downgrade by `extraPipPackages` | `["apache-airflow"]` -`airflow.extraEnv` | extra environment variables for the airflow Pods | `[]` +`airflow.extraEnv` | extra environment variables for the airflow Pods (will be templated) | `[]` `airflow.extraContainers` | extra containers for the airflow Pods | `[]` `airflow.extraInitContainers` | extra init-containers for the airflow Pods | `[]` `airflow.extraVolumeMounts` | extra VolumeMounts for the airflow Pods | `[]` diff --git a/charts/airflow/docs/faq/configuration/airflow-configs.md b/charts/airflow/docs/faq/configuration/airflow-configs.md index 85ee6db9..ed91d4a0 100644 --- a/charts/airflow/docs/faq/configuration/airflow-configs.md +++ b/charts/airflow/docs/faq/configuration/airflow-configs.md @@ -37,7 +37,9 @@ airflow: > 🟦 __Tip__ 🟦 > -> To store sensitive configs in Kubernetes secrets, you may use the `airflow.extraEnv` value. +> To store sensitive configs in Kubernetes secrets, you may use the `airflow.extraEnv` value to mount extra environment variables +> with the same structure as [EnvVar in ContainerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envvar-v1-core). +> These values will be templated by Helm, so you can use variables or template functions. > > For example, to set `AIRFLOW__CORE__FERNET_KEY` from a Secret called `airflow-fernet-key` containing a key called `value`: > diff --git a/charts/airflow/docs/faq/kubernetes/mount-environment-variables.md b/charts/airflow/docs/faq/kubernetes/mount-environment-variables.md index d0884ceb..09e0fd24 100644 --- a/charts/airflow/docs/faq/kubernetes/mount-environment-variables.md +++ b/charts/airflow/docs/faq/kubernetes/mount-environment-variables.md @@ -4,7 +4,7 @@ # Mount Environment Variables from Secrets/ConfigMaps -You may use the `airflow.extraEnv` value to mount extra environment variables with the same structure as [EnvVar in ContainerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envvar-v1-core). +You may use the `airflow.extraEnv` value to mount extra environment variables with the same structure as [EnvVar in ContainerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envvar-v1-core). These values will be templated by Helm, so you can use variables or template functions. > 🟦 __Tip__ 🟦 > @@ -20,4 +20,13 @@ airflow: secretKeyRef: name: airflow-fernet-key key: value +``` + +Here is an example which sets `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER` with a templated value: + +```yaml +airflow: + extraEnv: + - name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER + value: "s3://{{ .Release.Namespace }}-airflow/logs" ``` \ No newline at end of file diff --git a/charts/airflow/templates/_helpers/pods.tpl b/charts/airflow/templates/_helpers/pods.tpl index a0c08179..93710065 100644 --- a/charts/airflow/templates/_helpers/pods.tpl +++ b/charts/airflow/templates/_helpers/pods.tpl @@ -624,6 +624,6 @@ EXAMPLE USAGE: {{ include "airflow.env" (dict "Release" .Release "Values" .Value {{- /* user-defined environment variables */ -}} {{- if .Values.airflow.extraEnv }} -{{ toYaml .Values.airflow.extraEnv }} +{{ tpl (toYaml .Values.airflow.extraEnv) . }} {{- end }} {{- end }} diff --git a/charts/airflow/values.yaml b/charts/airflow/values.yaml index 53eaeed3..fe0e8aea 100644 --- a/charts/airflow/values.yaml +++ b/charts/airflow/values.yaml @@ -239,7 +239,7 @@ airflow: protectedPipPackages: - "apache-airflow" - ## extra environment variables for the airflow Pods + ## extra environment variables for the airflow Pods (will be templated) ## - spec for EnvVar: ## https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envvar-v1-core ##