{{- include "home-assistant.validateController" . }} {{- if eq .Values.controller.type "StatefulSet" }} apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "home-assistant.fullname" . }} labels: {{- include "home-assistant.labels" . | nindent 4 }} {{- if .Values.statefulSetAnnotations }} annotations: {{- toYaml .Values.statefulSetAnnotations | nindent 4 }} {{- end }} spec: serviceName: {{ include "home-assistant.fullname" . }} replicas: {{ .Values.replicaCount }} selector: matchLabels: {{- include "home-assistant.selectorLabels" . | nindent 6 }} template: metadata: labels: {{- include "home-assistant.selectorLabels" . | nindent 8 }} annotations: {{- if .Values.configuration.enabled }} checksum/init-script: {{ include (print $.Template.BasePath "/configmap-init-script.yaml") . | sha256sum }} checksum/hass-configuration: {{ include (print $.Template.BasePath "/configmap-hass-config.yaml") . | sha256sum }} {{- end }} {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} spec: {{- if .Values.hostNetwork }} hostNetwork: true {{- end }} {{- if .Values.dnsPolicy }} dnsPolicy: {{ .Values.dnsPolicy }} {{- end }} {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "home-assistant.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} {{- if .Values.dnsConfig }} dnsConfig: {{- toYaml .Values.dnsConfig | nindent 8 }} {{- end }} containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.envFrom }} envFrom: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.env }} env: {{- toYaml . | nindent 12 }} {{- end }} ports: - name: http containerPort: 8123 protocol: TCP {{- if .Values.hostPort.enabled }} hostPort: {{ .Values.hostPort.port }} {{- end }} {{- if .Values.additionalPorts }} {{- .Values.additionalPorts | toYaml | nindent 12 }} {{- end }} {{- with $.Values.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with $.Values.readinessProbe }} readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with $.Values.startupProbe }} startupProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} volumeMounts: - mountPath: /config name: {{ include "home-assistant.fullname" . }} {{- if .Values.additionalMounts }} {{- .Values.additionalMounts | toYaml | nindent 10 }} {{- end }} {{- if .Values.addons.codeserver.enabled }} - name: codeserver securityContext: {{- toYaml .Values.securityContext | nindent 12 }} args: - --auth - none - --user-data-dir - "/config/.vscode" - --extensions-dir - "/config/.vscode" - --port - "12321" - "/config" image: "{{ .Values.addons.codeserver.image.repository }}:{{ .Values.addons.codeserver.image.tag }}" imagePullPolicy: "{{ .Values.addons.codeserver.image.pullPolicy }}" ports: - containerPort: 12321 name: codeserver protocol: TCP {{- with .Values.addons.codeserver.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} volumeMounts: - mountPath: /config name: {{ include "home-assistant.fullname" . }} {{- if .Values.addons.codeserver.additionalMounts }} {{- .Values.addons.codeserver.additionalMounts | toYaml | nindent 10 }} {{- end }} {{- end }} {{- if or (.Values.configuration.enabled) .Values.initContainers }} initContainers: {{- if .Values.initContainers }} {{- toYaml .Values.initContainers | nindent 8 }} {{- end }} {{- if .Values.configuration.enabled }} - name: {{ .Values.configuration.initContainer.name }} image: {{ .Values.configuration.initContainer.image }} {{- if .Values.configuration.initContainer.securityContext }} securityContext: {{- toYaml .Values.configuration.initContainer.securityContext | nindent 12 }} {{- end }} {{- if .Values.configuration.initContainer.command }} command: {{ toYaml .Values.configuration.initContainer.command | nindent 12 }} {{- end }} {{- if .Values.configuration.initContainer.args }} args: {{ toYaml .Values.configuration.initContainer.args | nindent 12 }} {{- end }} {{- if .Values.configuration.initContainer.env }} env: {{- toYaml .env | nindent 12 }} {{- end }} volumeMounts: {{- range .Values.configuration.initContainer.volumeMounts }} - name: {{ .name }} mountPath: {{ .mountPath }} {{- if .subPath }} subPath: {{ .subPath }} {{ end }} {{- end }} - mountPath: /config name: {{ include "home-assistant.fullname" $ }} {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.priorityClassName }} priorityClassName: {{ .Values.priorityClassName }} {{- end }} volumes: {{- if .Values.configuration.enabled }} - name: init-volume configMap: name: init-script - name: config-volume configMap: name: hass-configuration {{- end }} {{- if not .Values.persistence.enabled }} - name: {{ include "home-assistant.fullname" . }} emptyDir: {} {{- end }} {{- if .Values.additionalVolumes }} {{- .Values.additionalVolumes | toYaml | nindent 6 }} {{- end }} {{- if .Values.persistence.enabled }} volumeClaimTemplates: - metadata: name: {{ include "home-assistant.fullname" . }} {{- with .Values.persistence.annotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} spec: accessModes: - {{ .Values.persistence.accessMode }} {{- if .Values.persistence.existingVolume }} volumeName: {{ .Values.persistence.existingVolume }} {{- end }} {{- if or .Values.persistence.matchLabels (.Values.persistence.matchExpressions) }} selector: {{- if .Values.persistence.matchLabels }} matchLabels: {{ toYaml .Values.persistence.matchLabels | indent 8 }} {{- end -}} {{- if .Values.persistence.matchExpressions }} matchExpressions: {{ toYaml .Values.persistence.matchExpressions | indent 8 }} {{- end -}} {{- end }} resources: requests: storage: {{ .Values.persistence.size }} {{- if .Values.persistence.storageClass }} storageClassName: {{ .Values.persistence.storageClass }} {{- end }} {{- end }} {{- end }}