From a663746686fa31494f79a604471e1052d98786fc Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Sat, 16 Aug 2025 07:55:10 -0700 Subject: [PATCH] Add homeassistant app. --- apps/homeassistant/config-job.yaml | 37 +++++++++++ apps/homeassistant/deployment.yaml | 88 +++++++++++++++++++++++++++ apps/homeassistant/ingress.yaml | 23 +++++++ apps/homeassistant/kustomization.yaml | 16 +++++ apps/homeassistant/manifest.yaml | 13 ++++ apps/homeassistant/namespace.yaml | 4 ++ apps/homeassistant/pvc.yaml | 11 ++++ apps/homeassistant/service.yaml | 12 ++++ 8 files changed, 204 insertions(+) create mode 100644 apps/homeassistant/config-job.yaml create mode 100644 apps/homeassistant/deployment.yaml create mode 100644 apps/homeassistant/ingress.yaml create mode 100644 apps/homeassistant/kustomization.yaml create mode 100644 apps/homeassistant/manifest.yaml create mode 100644 apps/homeassistant/namespace.yaml create mode 100644 apps/homeassistant/pvc.yaml create mode 100644 apps/homeassistant/service.yaml diff --git a/apps/homeassistant/config-job.yaml b/apps/homeassistant/config-job.yaml new file mode 100644 index 0000000..3126c35 --- /dev/null +++ b/apps/homeassistant/config-job.yaml @@ -0,0 +1,37 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: homeassistant-config-setup +spec: + template: + spec: + restartPolicy: Never + containers: + - name: config-setup + image: busybox:1.35 + command: ['sh', '-c'] + args: + - | + # Wait for config file to exist + while [ ! -f /config/configuration.yaml ]; do + sleep 5 + done + + # Add HTTP config if not present + if ! grep -q "use_x_forwarded_for" /config/configuration.yaml; then + echo "" >> /config/configuration.yaml + echo "# HTTP configuration for reverse proxy support" >> /config/configuration.yaml + echo "http:" >> /config/configuration.yaml + echo " use_x_forwarded_for: true" >> /config/configuration.yaml + echo " trusted_proxies:" >> /config/configuration.yaml + echo " - 10.0.0.0/8" >> /config/configuration.yaml + echo " - 172.16.0.0/12" >> /config/configuration.yaml + echo " - 192.168.0.0/16" >> /config/configuration.yaml + fi + volumeMounts: + - mountPath: /config + name: homeassistant-config + volumes: + - name: homeassistant-config + persistentVolumeClaim: + claimName: homeassistant-pvc \ No newline at end of file diff --git a/apps/homeassistant/deployment.yaml b/apps/homeassistant/deployment.yaml new file mode 100644 index 0000000..e25cd7a --- /dev/null +++ b/apps/homeassistant/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: homeassistant +spec: + replicas: 1 + selector: + matchLabels: + component: homeassistant + strategy: + type: Recreate + template: + metadata: + labels: + component: homeassistant + spec: + # hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + initContainers: + - name: config-setup + image: busybox:1.35 + command: ['sh', '-c'] + args: + - | + # Create initial config if it doesn't exist + if [ ! -f /config/configuration.yaml ]; then + cat > /config/configuration.yaml << 'EOF' + # Loads default set of integrations. Do not remove. + default_config: + + # Load frontend themes from the themes folder + frontend: + themes: !include_dir_merge_named themes + + automation: !include automations.yaml + script: !include scripts.yaml + scene: !include scenes.yaml + + # HTTP configuration for reverse proxy support + http: + use_x_forwarded_for: true + trusted_proxies: + - 10.0.0.0/8 + - 172.16.0.0/12 + - 192.168.0.0/16 + EOF + fi + volumeMounts: + - mountPath: /config + name: homeassistant-config + containers: + - name: homeassistant + image: "{{ .apps.homeassistant.image }}" + ports: + - containerPort: 8123 + protocol: TCP + env: + - name: TZ + value: "{{ .apps.homeassistant.timezone }}" + volumeMounts: + - mountPath: /config + name: homeassistant-config + readOnly: false + resources: + requests: + memory: "512Mi" + cpu: "250m" + limits: + memory: "2Gi" + cpu: "2" + livenessProbe: + httpGet: + path: / + port: 8123 + initialDelaySeconds: 30 + periodSeconds: 30 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 8123 + initialDelaySeconds: 15 + periodSeconds: 15 + timeoutSeconds: 5 + volumes: + - name: homeassistant-config + persistentVolumeClaim: + claimName: homeassistant-pvc diff --git a/apps/homeassistant/ingress.yaml b/apps/homeassistant/ingress.yaml new file mode 100644 index 0000000..f215f14 --- /dev/null +++ b/apps/homeassistant/ingress.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: homeassistant-public + # annotations: + # external-dns.alpha.kubernetes.io/target: "{{ .apps.homeassistant.domain }}" + # external-dns.alpha.kubernetes.io/cloudflare-proxied: "false" +spec: + rules: + - host: "{{ .apps.homeassistant.domain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: homeassistant + port: + number: 8123 + tls: + - secretName: "{{ .apps.homeassistant.tlsKey }}" + hosts: + - "{{ .apps.homeassistant.domain }}" \ No newline at end of file diff --git a/apps/homeassistant/kustomization.yaml b/apps/homeassistant/kustomization.yaml new file mode 100644 index 0000000..83261e2 --- /dev/null +++ b/apps/homeassistant/kustomization.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: homeassistant +labels: + - includeSelectors: true + pairs: + app: homeassistant + managedBy: kustomize + partOf: wild-cloud +resources: + - namespace.yaml + - deployment.yaml + - service.yaml + - ingress.yaml + - pvc.yaml + diff --git a/apps/homeassistant/manifest.yaml b/apps/homeassistant/manifest.yaml new file mode 100644 index 0000000..aa9c356 --- /dev/null +++ b/apps/homeassistant/manifest.yaml @@ -0,0 +1,13 @@ +name: homeassistant +install: true +description: Home Assistant is an open source home automation platform that puts local control and privacy first. +version: 2025.1.0 +icon: https://brands.home-assistant.io/homeassistant/logo.png +requires: [] +defaultConfig: + image: ghcr.io/home-assistant/home-assistant:stable + timezone: UTC + storage: 50Gi + domain: hass.{{ .cloud.internalDomain }} + tlsSecretName: wildcard-internal-wild-cloud-tls +requiredSecrets: [] diff --git a/apps/homeassistant/namespace.yaml b/apps/homeassistant/namespace.yaml new file mode 100644 index 0000000..fb010f6 --- /dev/null +++ b/apps/homeassistant/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: homeassistant \ No newline at end of file diff --git a/apps/homeassistant/pvc.yaml b/apps/homeassistant/pvc.yaml new file mode 100644 index 0000000..d5ab892 --- /dev/null +++ b/apps/homeassistant/pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: homeassistant-pvc +spec: + storageClassName: longhorn + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .apps.homeassistant.storage }} \ No newline at end of file diff --git a/apps/homeassistant/service.yaml b/apps/homeassistant/service.yaml new file mode 100644 index 0000000..1efe712 --- /dev/null +++ b/apps/homeassistant/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: homeassistant +spec: + ports: + - name: http + port: 8123 + targetPort: 8123 + protocol: TCP + selector: + component: homeassistant