Search code examples
airflowgoogle-kubernetes-enginekubernetes-helmairflow-2.xkubernetes-secrets

airflow 2 helm chart - how to specify mysql connection string


I'm deploying Airflow 2 on GKE Autopilot using helm chart and have provisioned a Cloud SQL instance (MySQL) to be used as DB by airflow.

I have created (using kubectl) a secret in K8s with this connection string as value and wanted to give that as an env var to all airflow pods. So tried to provide that in

env: []
  

section of this chart (line no 239), but it can not use valueFrom attribute there. It need value. So I want to know what are the ways by which I can refer to a secret in this helm chart and provide that as env var value to all the containers this chart deploys


Solution

  • You can checkout the line no. 244 which is injecting the secret to all PODs

    it will also i think do same think as we can inject the secret as env variable so.

    # Secrets for all airflow containers
    secret: []
    # - envName: ""
    #   secretName: ""
    #   secretKey: ""
    

    values.yaml : https://github.com/apache/airflow/blob/main/chart/values.yaml#L243

    Documentation details : https://github.com/apache/airflow/blob/main/docs/helm-chart/adding-connections-and-variables.rst#connections-and-sensitive-environment-variables