question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Airflow Helm charts - better integration with Hashicorp Vault

See original GitHub issue

Hello, I have an Airflow 2.1 deployment on kubernetes which is integrated with Hashicorp Vault as secure backend. I found out that the integration will be fully completed only when we get rid of two more keys which I am obligated to apply as secrets:

  • gitSync ssh file
  • Fernet key The easiest way would be if they could be loaded the same way the hashicorp vault provider client is loading its token from a file. For example i have the ssh key and the fernet key in vault as secrets which are injected by the Vault agent as pod annotations:
  vault.hashicorp.com/agent-inject-secret-airflow: "k8s-secrets/int/airflow"
  vault.hashicorp.com/role: "airflow"
  vault.hashicorp.com/agent-inject-template-airflow: |
    {{- with secret "k8s-secrets/int/airflow" -}}
    {{ .Data.vaulttoken -}}
    {{- end }}
  vault.hashicorp.com/agent-inject-secret-gitssh: "k8s-secrets/int/airflow"
  vault.hashicorp.com/agent-inject-template-gitssh: |
    {{- with secret "k8s-secrets/skube-int/airflow" -}}
    {{ .Data.gitssh -}}
    {{- end }}
  vault.hashicorp.com/agent-inject-secret-fernetkey: "k8s-secrets/int/airflow"
  vault.hashicorp.com/agent-inject-template-fernetkey: |
    {{- with secret "k8s-secrets/skube-int/airflow" -}}
    {{ .Data.fernetkey -}}
    {{- end }}

Then in /vault/secrets/ i have all the three files. The current configuration for GIT_SSH_KEY_FILE for Git-Sync SSH key is (in the _helpers.yaml file):

    {{- if .Values.dags.gitSync.sshKeySecret }}
    - name: GIT_SSH_KEY_FILE
      value: "/etc/git-secret/ssh"
    - name: GIT_SYNC_SSH
      value: "true" 

So there we might have another parameter Values.dags.gitSync.sshKeySecretFile which will point to the injected secret.

The Fernet Key however is a different story as its either written in the config, loaded from an ENV var or loaded from a secret:

  # Hard Coded Airflow Envs
  - name: AIRFLOW__CORE__FERNET_KEY
    valueFrom:
      secretKeyRef:
        name: {{ template "fernet_key_secret" . }}
        key: fernet-key

I am still not sure this could be implemented to read from a file. At first glance there are two solutions:

  • Add an additional mechanism in the Airflow core to load the fernet from a file - this requires a lot of work i guess.
  • Inject the key in the file as an export command: export AIRFLOW__CORE__FERNET_KEY={{ .Data.fernetkey -}} - this will probably require an additional script in the entrypoint of the container to execute the file

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
potiukcommented, Jul 3, 2021

How about we simply add an option “AIRFLOW__CORE__FERNET_KEY_FILE” in Airflow and read the key from there? this would be like a few line change. AS you might see from #16684, I do not feel particular warmth for the _CMD pattern. While flexible, it’s also dangerous and might lead to promote bad behaviour and maybe just being able to specify file name for the FERNET_KEY is a nice, generic solution tha can solve this particular problem?

0reactions
github-actions[bot]commented, Aug 10, 2021

This issue has been closed because it has not received response from the issue author.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Airflow Helm charts - better integration with Hashicorp Vault
Stormhand opened a new issue #16769: URL: https://github.com/apache/airflow/issues/16769. Hello, I have an Airflow 2.1 deployment on ...
Read more >
Helm Chart Allow for Empty data settings #16684 - GitHub
Due to Airflows configuration precedence (https://airflow.apache.org/docs/apache- ... Airflow Helm charts - better integration with Hashicorp Vault #16769.
Read more >
How To Setup HashiCorp Vault with Airflow
How to setup and use HashiCorp Vault with Airflow to retrieve connections, secrets and variables. Works for Google Cloud Platform and Amazon ...
Read more >
Injecting Vault Secrets Into Kubernetes Pods via a Sidecar
For this blog, the focus is on using the Vault Helm Chart, as that is likely a good starting point for learning about...
Read more >
Kubernetes and Vault integration - Halodoc Blog
Hashicorp provides a vault-agent as a sidecar solution which fits into ... the very first time, you can proceed with the vault helm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found