stable/airflow connect external PostgreSQL database

Viewed 1232

I am deploying airflow into Kubernetes using: https://github.com/helm/charts/tree/master/stable/airflow

I am trying to connect my external PostgreSQL database by modifying the values.yml:

externalDatabase:
  ## the type of external database: {mysql,postgres}
  ##
  type: postgres

  ## the host of the external database
  ##
  host: <HOST>

  ## the port of the external database
  ##
  port: 5432

  ## the database/scheme to use within the the external database
  ##
  database: airflow

  ## the user of the external database
  ##
  user: <USER>

  ## the name of a pre-created secret containing the external database password
  ##
  passwordSecret: ""

  ## the key within `externalDatabase.passwordSecret` containing the password string
  ##
  passwordSecretKey: ""

  ## the connection properties for external database, e.g. "?sslmode=require"
  properties: "?sslmode=require"

But it is requesting passwordSecretand passwordSecretKey.

How I can create passwordSecret secret in Kubernetes?

passwordSecretKey is the password for the airflow user?

2 Answers

The easiest way is to follow the steps here.

Create a yaml file called mysecretcreator.yaml

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  username: YWRtaW4=
  password: MWYyZDFlMmU2N2Rm

And then run kubectl apply -f mysecretcreator.yaml

Once the secret has been created, add the following to the custom-values.yaml

  ## the name of a pre-created secret containing the external database password
  ##
  passwordSecret: "mysecret"

Since you have defined your username as a string you can just have the password in the data/StringData field in secrets.yaml file. Using string data link

apiVersion: v1
kind: Secret
metadata:
  name: airflow-postgres-key
  namespace: airflow
type: Opaque
stringData:
  passwd: mypas_sword=

You can refer these in your values.yaml file as

## the user of the external database
  ##
  user: <USER_Name>

  ## the name of a pre-created secret containing the external database password
  ##
  passwordSecret: airflow-postgres-key

  ## the key within `externalDatabase.passwordSecret` containing the password string
  ##
  passwordSecretKey: passwd
Related