apache / apache/airflow

[Helm Chart] Redis and Fernet Secret using pre-install hooks instead of lookup functions

Open
#44,164 3 comments 0 reactions 0 assignees View on GitHub
area:core area:helm-chart kind:bug
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Apache Airflow version

main (development)

### If "Other Airflow 2 version" selected, which one?

_No response_

### What happened?

Problem:

I was trying to use airflow as a child chart and noticed I couldn't upgrade my existing chart because the fernet secret would not get created.

templates/configmaps/extra-configmaps.yaml: {{- $_ := set $annotations "helm.sh/hook" "pre-install,pre-upgrade" }}
templates/secrets/extra-secrets.yaml: {{- $_ := set $annotations "helm.sh/hook" "pre-install,pre-upgrade" }}
templates/secrets/fernetkey-secret.yaml: "helm.sh/hook": "pre-install"
templates/secrets/redis-secrets.yaml:# relying on the "pre-install" hack to prevent changing randomly generated passwords,
templates/secrets/redis-secrets.yaml: "helm.sh/hook": "pre-install"
templates/secrets/redis-secrets.yaml: "helm.sh/hook": "pre-install"

There are a couple references to secrets, fernet and redis secret that are using the pre-install hook to avoid them changing during helm upgrade

I think this could be done with a lookup function instead

```
apiVersion: v1
kind: Secret
metadata:
name: my-secret
labels:
type: Opaque
data:
{{- $previousSecret := lookup "v1" "Secret" .Release.Namespace "my-secret" }}
{{- if $previousSecret }}
"mysecret": {{ $previousSecret.data.mysecret }}
{{- else if .Values.mySecret }}
"mysecret": {{ .Values.mySecret | b64enc | quote }}
{{- else }}
"mysecret": {{ randAlphaNum 32 | b64enc | quote }}
{{- end }}

```
Because it seems that this pre-install hook was done more as a workaround than anything.

### What you think should happen instead?

I think fernet secret should get created on helm upgrade if it does not exist.

### How to reproduce

Try using airflow as a child chart that already has a deployed release.

### Operating System

Fedora 40

### Versions of Apache Airflow Providers

_No response_

### Deployment

Official Apache Airflow Helm Chart

### Deployment details

_No response_

### Anything else?

_No response_

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start with templates/secrets/fernetkey-secret.yaml and templates/secrets/redis-secrets.yaml, then compare the hook annotations in templates/configmaps/extra-configmaps.yaml and templates/secrets/extra-secrets.yaml. Reproduce an upgrade with Airflow deployed as a child chart and verify that missing Fernet secrets are created on upgrade while existing Redis and Fernet secret values are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes, redis
Domain
devops, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.