feat: Add support for HA secrets management with init container and configuration options

This commit is contained in:
sha
2026-03-18 14:37:28 +02:00
parent c632968e49
commit 83e9c35f19
2 changed files with 34 additions and 1 deletions
+29 -1
View File
@@ -25,8 +25,30 @@ spec:
hostNetwork: true hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
{{- end }} {{- end }}
{{- if .Values.postgres.enabled }} {{- if or .Values.postgres.enabled .Values.haSecrets.enabled }}
initContainers: initContainers:
{{- if .Values.haSecrets.enabled }}
- name: init-secrets
image: busybox:latest
command:
- /bin/sh
- -c
- |
# Build secrets.yaml from mounted K8s secret
echo "# Managed by Helm - do not edit manually" > /config/secrets.yaml
for f in /ha-secrets/*; do
key=$(basename "$f")
val=$(cat "$f")
echo "$key: \"$val\"" >> /config/secrets.yaml
done
volumeMounts:
- name: config
mountPath: /config
- name: ha-secrets
mountPath: /ha-secrets
readOnly: true
{{- end }}
{{- if .Values.postgres.enabled }}
- name: init-recorder - name: init-recorder
image: busybox:latest image: busybox:latest
command: command:
@@ -56,6 +78,7 @@ spec:
- name: config - name: config
mountPath: /config mountPath: /config
{{- end }} {{- end }}
{{- end }}
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
@@ -101,6 +124,11 @@ spec:
path: {{ .Values.persistence.media.hostPath }} path: {{ .Values.persistence.media.hostPath }}
type: DirectoryOrCreate type: DirectoryOrCreate
{{- end }} {{- end }}
{{- if .Values.haSecrets.enabled }}
- name: ha-secrets
secret:
secretName: {{ .Values.haSecrets.existingSecret }}
{{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
+5
View File
@@ -60,6 +60,11 @@ persistence:
hostPath: /srv/data/home-assistant/media hostPath: /srv/data/home-assistant/media
mountPath: /media mountPath: /media
haSecrets:
enabled: false
# K8s Secret containing key-value pairs to write as /config/secrets.yaml
existingSecret: ""
postgres: postgres:
enabled: false enabled: false
host: postgres-tcp.postgres.svc.cluster.local host: postgres-tcp.postgres.svc.cluster.local