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 and the HTTP (reverse proxy) store 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 if [ ! -f /config/.storage/http ]; then mkdir -p /config/.storage cp /seed/http.json /config/.storage/http echo "seeded .storage/http (reverse proxy)" 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 }}