diff --git a/homeassistant/.helmignore b/homeassistant/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/homeassistant/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/homeassistant/Chart.yaml b/homeassistant/Chart.yaml new file mode 100644 index 0000000..584f2d9 --- /dev/null +++ b/homeassistant/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: homeassistant +description: A Helm chart to deploy Home Assistant on Kubernetes +type: application + +version: 1.0.0-release-2026-2-3 + +appVersion: "2026.2.3" diff --git a/homeassistant/templates/NOTES.txt b/homeassistant/templates/NOTES.txt new file mode 100644 index 0000000..dc3f3b9 --- /dev/null +++ b/homeassistant/templates/NOTES.txt @@ -0,0 +1,35 @@ +1. Get the application URL by running these commands: +{{- if .Values.httpRoute.enabled }} +{{- if .Values.httpRoute.hostnames }} + export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }} +{{- else }} + export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}") + {{- end }} +{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }} + echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application" + + NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules. + The rules can be set for path, method, header and query parameters. + You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml' +{{- end }} +{{- else if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "homeassistant.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "homeassistant.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "homeassistant.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "homeassistant.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/homeassistant/templates/_helpers.tpl b/homeassistant/templates/_helpers.tpl new file mode 100644 index 0000000..7090d85 --- /dev/null +++ b/homeassistant/templates/_helpers.tpl @@ -0,0 +1,5 @@ + +{{- define "homeassistant.release" -}} +{{- printf "%s-%s" .Release.Name .Chart.Name }} +{{- end }} + diff --git a/homeassistant/templates/homeassistant.ingress.yaml b/homeassistant/templates/homeassistant.ingress.yaml new file mode 100644 index 0000000..dc23b73 --- /dev/null +++ b/homeassistant/templates/homeassistant.ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: "{{ include "homeassistant.release" . }}-ingress" + labels: + app: "{{ include "homeassistant.release" . }}" + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: "{{ include "homeassistant.release" . }}-service" + port: + name: http + {{- end }} + {{- end }} +{{- end }} diff --git a/homeassistant/templates/homeassistant.service.yaml b/homeassistant/templates/homeassistant.service.yaml new file mode 100644 index 0000000..81fb0dd --- /dev/null +++ b/homeassistant/templates/homeassistant.service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{ include "homeassistant.release" . }}-service" + labels: + app: "{{ include "homeassistant.release" . }}" +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: "{{ include "homeassistant.release" . }}" diff --git a/homeassistant/templates/homeassistant.sfs.yaml b/homeassistant/templates/homeassistant.sfs.yaml new file mode 100644 index 0000000..e57db3d --- /dev/null +++ b/homeassistant/templates/homeassistant.sfs.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: "{{ include "homeassistant.release" . }}-sfs" + labels: + app: "{{ include "homeassistant.release" . }}" +spec: + replicas: 1 + selector: + matchLabels: + app: "{{ include "homeassistant.release" . }}" + template: + metadata: + name: "{{ include "homeassistant.release" . }}-sfs" + spec: + automountServiceAccountToken: false + containers: + - name: "{{ include "homeassistant.release" . }}" + image: "ghcr.io/home-assistant/home-assistant:{{ .Chart.AppVersion }}" + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8123 + protocol: TCP + # TODO: liveness-probe, readiness-probe + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + # TODO: volume mounts + # TODO: volumes + # TODO: bind to local nodes \ No newline at end of file diff --git a/homeassistant/templates/tests/test-connection.yaml b/homeassistant/templates/tests/test-connection.yaml new file mode 100644 index 0000000..b668ddb --- /dev/null +++ b/homeassistant/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "homeassistant.fullname" . }}-test-connection" + labels: + {{- include "homeassistant.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "homeassistant.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/homeassistant/values.yaml b/homeassistant/values.yaml new file mode 100644 index 0000000..556f376 --- /dev/null +++ b/homeassistant/values.yaml @@ -0,0 +1,60 @@ +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: + limits: + cpu: 1 + memory: 256Mi + requests: + cpu: 0.2 + memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {}