From 9f8ce47986112a7c035b6efa536dc049d8681808 Mon Sep 17 00:00:00 2001 From: SmokyZone Date: Sun, 18 Oct 2026 14:01:34 +0200 Subject: [PATCH] Add Home Assistant chart Co-Authored-By: Claude Opus 5.5 --- Chart.yaml | 14 +++++++ README.md | 47 ++++++++++++++++++++++ templates/_helpers.tpl | 10 +++++ templates/configmap.yaml | 9 +++++ templates/deployment.yaml | 82 +++++++++++++++++++++++++++++++++++++++ templates/ingress.yaml | 29 ++++++++++++++ templates/pvc.yaml | 18 +++++++++ templates/service.yaml | 13 +++++++ values.yaml | 60 ++++++++++++++++++++++++++++ 9 files changed, 282 insertions(+) create mode 100644 Chart.yaml create mode 100644 README.md create mode 100644 templates/_helpers.tpl create mode 100644 templates/configmap.yaml create mode 100644 templates/deployment.yaml create mode 100644 templates/ingress.yaml create mode 100644 templates/pvc.yaml create mode 100644 templates/service.yaml create mode 100644 values.yaml diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..560d57a --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: homeassistant +description: Home Assistant (container install) on the home cluster +type: application +version: 0.1.0 +appVersion: "2026.10.2" +home: https://git.smokyzone.de/SmokyZone/homeassistant-gitops +sources: + - https://git.smokyzone.de/SmokyZone/homeassistant-gitops +keywords: + - home-assistant + - smart-home +maintainers: + - name: SmokyZone diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ee297b --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# homeassistant-gitops + +Helm chart for [Home Assistant](https://www.home-assistant.io/) (container install) on the +single-node cluster (`loki`), deployed by ArgoCD via the `apps-in-apps` repo into the +namespace `homeassistant`. + +URL: https://homeassistant.smokyzone.de:30444 (LAN / Tailscale only; the DNS record +points at the node's private IP `192.168.2.218`). Certificate from +`letsencrypt-dns-cloudflare` (DNS-01). + +## Design + +- **hostNetwork**: HA runs in the node's network namespace so LAN discovery (mDNS/SSDP: + Chromecast, Hue, Sonos, HomeKit, ...) works. Side effect: plain HTTP is also served on + `http://192.168.2.218:8123` in the LAN. Set `hostNetwork: false` if you don't need + discovery. +- **Config** lives on the `local-path` PVC `homeassistant-config` (`/config`), which is kept + when the app is deleted. Back it up (users, integrations, history are in there). +- **configuration.yaml** is seeded once by an init container (see `seedConfiguration` in + `values.yaml`), including the reverse-proxy block: + + ```yaml + http: + use_x_forwarded_for: true + trusted_proxies: [10.1.0.0/16, 127.0.0.1] + ``` + + Without it HA answers `400 Bad Request` through the ingress. After the first start the + file is yours; the chart never overwrites it. Edit it with + `kubectl -n homeassistant exec -it deploy/homeassistant -- vi /config/configuration.yaml` + and restart the pod (or *Developer tools → YAML → Restart* in the UI). +- **USB radios** (Zigbee/Z-Wave): list the device under `devices:` (prefer + `/dev/serial/by-id/...`) and set `privileged: true`. +- This is the container install: there is no add-on store (Supervisor). Add-ons such as + Mosquitto or Zigbee2MQTT would run as their own deployments in the cluster. + +## First start + +1. Open https://homeassistant.smokyzone.de:30444 and create the owner account during + onboarding (first visitor becomes the owner, so do this right away). +2. Home location / units / language (Deutsch) in the onboarding wizard. +3. Companion app: server URL `https://homeassistant.smokyzone.de:30444` (works at home and + via Tailscale). + +## Upgrades + +Bump `image.tag` in `values.yaml` (see the release notes for breaking changes first). diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..7a133f3 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,10 @@ +{{- define "ha.labels" -}} +app.kubernetes.io/name: homeassistant +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "ha.selectorLabels" -}} +app.kubernetes.io/name: homeassistant +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/templates/configmap.yaml b/templates/configmap.yaml new file mode 100644 index 0000000..f9cf746 --- /dev/null +++ b/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: homeassistant-seed + labels: + {{- include "ha.labels" . | nindent 4 }} +data: + configuration.yaml: | + {{- .Values.seedConfiguration | nindent 4 }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml new file mode 100644 index 0000000..3d1a034 --- /dev/null +++ b/templates/deployment.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: homeassistant + labels: + {{- include "ha.labels" . | nindent 4 }} +spec: + replicas: 1 + # RWO volume + hostNetwork port: the old pod must be gone before the new one starts. + strategy: + type: Recreate + selector: + matchLabels: + {{- include "ha.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "ha.selectorLabels" . | nindent 8 }} + spec: + hostNetwork: {{ .Values.hostNetwork }} + # Keep cluster DNS (service names) working with hostNetwork. + dnsPolicy: {{ ternary "ClusterFirstWithHostNet" "ClusterFirst" .Values.hostNetwork }} + initContainers: + # Seed configuration.yaml (incl. reverse-proxy settings) on first start only. + - name: seed-config + image: busybox:1.36 + command: + - sh + - -c + - | + set -e + if [ ! -f /config/configuration.yaml ]; then + cp /seed/configuration.yaml /config/configuration.yaml + echo "seeded configuration.yaml" + fi + # Files included by the seeded configuration.yaml (same defaults as HA's onboarding). + [ -f /config/automations.yaml ] || echo "[]" > /config/automations.yaml + touch /config/scripts.yaml /config/scenes.yaml + mkdir -p /config/themes + volumeMounts: + - {name: config, mountPath: /config} + - {name: seed, mountPath: /seed} + containers: + - name: homeassistant + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + env: + - name: TZ + value: {{ .Values.tz | quote }} + ports: + - name: http + containerPort: {{ .Values.port }} + {{- if .Values.privileged }} + securityContext: + privileged: true + {{- end }} + startupProbe: + tcpSocket: {port: http} + periodSeconds: 10 + failureThreshold: 60 + livenessProbe: + tcpSocket: {port: http} + periodSeconds: 30 + failureThreshold: 5 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - {name: config, mountPath: /config} + {{- range $i, $d := .Values.devices }} + - {name: dev-{{ $i }}, mountPath: {{ $d }}} + {{- end }} + volumes: + - name: config + persistentVolumeClaim: + claimName: homeassistant-config + - name: seed + configMap: + name: homeassistant-seed + {{- range $i, $d := .Values.devices }} + - name: dev-{{ $i }} + hostPath: + path: {{ $d }} + {{- end }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml new file mode 100644 index 0000000..15ed4f1 --- /dev/null +++ b/templates/ingress.yaml @@ -0,0 +1,29 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: homeassistant + labels: + {{- include "ha.labels" . | nindent 4 }} + annotations: + cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }} + {{- with .Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + tls: + - hosts: [{{ .Values.ingress.host }}] + secretName: homeassistant-tls + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: homeassistant + port: + name: http +{{- end }} diff --git a/templates/pvc.yaml b/templates/pvc.yaml new file mode 100644 index 0000000..4670e46 --- /dev/null +++ b/templates/pvc.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: homeassistant-config + labels: + {{- include "ha.labels" . | nindent 4 }} + annotations: + # Never delete the config (users, integrations, history) on uninstall/prune. + helm.sh/resource-policy: keep + argocd.argoproj.io/sync-options: Delete=false +spec: + accessModes: [ReadWriteOnce] + {{- with .Values.persistence.storageClassName }} + storageClassName: {{ . }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} diff --git a/templates/service.yaml b/templates/service.yaml new file mode 100644 index 0000000..9a10b7a --- /dev/null +++ b/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: homeassistant + labels: + {{- include "ha.labels" . | nindent 4 }} +spec: + selector: + {{- include "ha.selectorLabels" . | nindent 4 }} + ports: + - name: http + port: {{ .Values.port }} + targetPort: http diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..067a2e9 --- /dev/null +++ b/values.yaml @@ -0,0 +1,60 @@ +## Values for the Home Assistant chart. + +image: + repository: ghcr.io/home-assistant/home-assistant + tag: "2026.10.2" + +tz: Europe/Berlin + +# Run in the node's network namespace. Required for LAN discovery (mDNS/SSDP: +# Chromecast, Hue, Sonos, HomeKit, ...), which does not cross the pod network. +# Side effect: port 8123 (plain HTTP) is also open on the node's LAN IP. +hostNetwork: true + +port: 8123 + +persistence: + # /config: configuration.yaml, .storage (users, integrations), SQLite recorder DB. + size: 5Gi + storageClassName: "" + +# Written to /config/configuration.yaml on first start only (when the file does not +# exist yet). Afterwards the file belongs to you; the chart never overwrites it. +# The http block lets HA accept requests from ingress-nginx (pod network 10.1.0.0/16); +# without it HA answers 400 Bad Request to proxied requests. +seedConfiguration: | + # Loads the default set of integrations. Do not remove. + default_config: + + http: + use_x_forwarded_for: true + trusted_proxies: + - 10.1.0.0/16 + - 127.0.0.1 + + frontend: + themes: !include_dir_merge_named themes + + automation: !include automations.yaml + script: !include scripts.yaml + scene: !include scenes.yaml + +ingress: + enabled: true + className: nginx + # ingress-nginx is NodePort-only: https://homeassistant.smokyzone.de:30444 + host: homeassistant.smokyzone.de + clusterIssuer: letsencrypt-dns-cloudflare + annotations: + # Websocket connection of the frontend / companion app stays open. + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-body-size: 100m + +# USB radios (Zigbee/Z-Wave sticks), e.g. /dev/serial/by-id/usb-...; needs privileged. +devices: [] +privileged: false + +resources: + requests: {cpu: 100m, memory: 512Mi} + limits: {cpu: "2", memory: 2Gi}