Files
kubernetes/home-assistant/kustomization.yaml
Dustin C. Hatch 832dea2c7d h-a: Add init container to wait for PostgreSQL
When Home Assistant starts, if PostgreSQL is unavailable, it will come
up successfully, but without the history component.  It never tries
again to connect and enable the component.  This makes it difficult to
detect the problem and thus easy to overlook the missing functionality.
To avoid having extended periods of missing state history, we'll force
Home Assistant to wait for PostgreSQL to come up before starting.
2024-01-21 19:50:54 -06:00

103 lines
2.8 KiB
YAML

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: home-assistant
labels:
- pairs:
app.kubernetes.io/instance: home-assistant
resources:
- namespace.yaml
- secrets.yaml
- home-assistant.yaml
- mosquitto-cert.yaml
- mosquitto.yaml
- zigbee2mqtt.yaml
- zwavejs2mqtt.yaml
- piper.yaml
- whisper.yaml
- ingress.yaml
configMapGenerator:
- name: home-assistant
files:
- configuration.yaml
- event-snapshot.sh
- groups.yaml
- restart-diddy-mopidy.sh
- shell-command.yaml
options:
disableNameSuffixHash: true
labels:
app.kubernetes.io/name: home-assistant
app.kubernetes.io/component: home-assistant
app.kubernetes.io/part-of: home-assistant
- name: mosquitto
files:
- mosquitto.conf
patches:
- patch: |-
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: home-assistant
spec:
template:
spec:
initContainers:
- name: waitfordb
image: docker.io/library/postgres:15
command:
- sh
- -c
- until pg_isready; do sleep 1; done
env:
- name: PGHOST
value: default.postgresql
- name: PGGDATABASE
value: homeassistant
- name: PGUSER
valueFrom:
secretKeyRef:
name: home-assistant.homeassistant.default.credentials.postgresql.acid.zalan.do
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: home-assistant.homeassistant.default.credentials.postgresql.acid.zalan.do
key: password
containers:
- name: home-assistant
env:
- name: RECORDER_DB_PASSWORD
valueFrom:
secretKeyRef:
name: home-assistant.homeassistant.default.credentials.postgresql.acid.zalan.do
key: password
- name: RECORDER_DB_USERNAME
valueFrom:
secretKeyRef:
name: home-assistant.homeassistant.default.credentials.postgresql.acid.zalan.do
key: username
- name: RECORDER_DB_URL
value: postgresql://$(RECORDER_DB_USERNAME):$(RECORDER_DB_PASSWORD)@default.postgresql/homeassistant
volumeMounts:
- mountPath: /run/config
name: home-assistant-config
readOnly: true
- mountPath: /run/secrets/home-assistant
name: home-assistant-secrets
readOnly: true
volumes:
- name: home-assistant-config
configMap:
name: home-assistant
defaultMode: 0600
- name: home-assistant-secrets
secret:
secretName: home-assistant
defaultMode: 0640