fix(home-assistant): init

This commit is contained in:
WrenIX 2024-03-26 10:56:05 +01:00
parent 9d7786a448
commit 151ef8b4da
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
20 changed files with 1540 additions and 0 deletions

View file

@ -8,6 +8,7 @@
** xref:grampsweb.adoc[grampsweb]
** xref:headscale.adoc[headscale]
** xref:headscale-ui.adoc[headscale-ui]
** xref:home-assistant.adoc[home-assistant]
** xref:hydrogen-web.adoc[hydrogen-web]
** xref:jellyfin.adoc[jellyfin]
** xref:matrix-authentication-service.adoc[matrix-authentication-service]

View file

@ -0,0 +1 @@
../../../../home-assistant/README.adoc

View file

@ -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/

View file

@ -0,0 +1,9 @@
apiVersion: v2
name: home-assistant
description: Home Assistant with tooling to run on an k3s pi
type: application
version: 0.1.0
appVersion: "2024.3.1"
maintainers:
- name: WrenIX
url: https://wrenix.eu

769
home-assistant/README.adoc Normal file
View file

@ -0,0 +1,769 @@
= home-assistant
image::https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square[Version: 0.1.0]
image::https://img.shields.io/badge/Version-application-informational?style=flat-square[Type: application]
image::https://img.shields.io/badge/AppVersion-2024.3.1-informational?style=flat-square[AppVersion: 2024.3.1]
== Maintainers
.Maintainers
|===
| Name | Email | Url
| WrenIX
|
| <https://wrenix.eu>
|===
== Usage
Helm must be installed and setup to your kubernetes cluster to use the charts.
Refer to Helm's https://helm.sh/docs[documentation] to get started.
Once Helm has been set up correctly, fetch the charts as follows:
[source,bash]
----
helm pull oci://codeberg.org/wrenix/helm-charts/home-assistant
----
You can install a chart release using the following command:
[source,bash]
----
helm install home-assistant-release oci://codeberg.org/wrenix/helm-charts/home-assistant --values values.yaml
----
To uninstall a chart release use `helm`'s delete command:
[source,bash]
----
helm uninstall home-assistant-release
----
== Values
.Values
|===
| Key | Type | Default | Description
| affinity
| object
| `{}`
|
| autoscaling.enabled
| bool
| `false`
|
| autoscaling.maxReplicas
| int
| `100`
|
| autoscaling.minReplicas
| int
| `1`
|
| autoscaling.targetCPUUtilizationPercentage
| int
| `80`
|
| fullnameOverride
| string
| `""`
|
| global.image.pullPolicy
| string
| `nil`
| if set it will overwrite all pullPolicy
| global.image.registry
| string
| `nil`
| if set it will overwrite all registry entries
| image.pullPolicy
| string
| `"IfNotPresent"`
|
| image.registry
| string
| `"ghcr.io"`
|
| image.repository
| string
| `"home-assistant/home-assistant"`
|
| image.tag
| string
| `""`
|
| imagePullSecrets
| list
| `[]`
|
| ingress.annotations
| object
| `{}`
|
| ingress.className
| string
| `""`
|
| ingress.enabled
| bool
| `false`
|
| ingress.hosts[0].host
| string
| `"chart-example.local"`
|
| ingress.hosts[0].paths[0].path
| string
| `"/"`
|
| ingress.hosts[0].paths[0].pathType
| string
| `"ImplementationSpecific"`
|
| ingress.tls
| list
| `[]`
|
| livenessProbe.httpGet.path
| string
| `"/"`
|
| livenessProbe.httpGet.port
| string
| `"http"`
|
| nameOverride
| string
| `""`
|
| nats.enabled
| bool
| `true`
|
| nats.image.pullPolicy
| string
| `"IfNotPresent"`
|
| nats.image.registry
| string
| `"docker.io"`
|
| nats.image.repository
| string
| `"library/nats"`
|
| nats.image.tag
| string
| `"2.10.12-scratch"`
|
| nats.livenessProbe.tcpSocket.port
| string
| `"nats"`
|
| nats.readinessProbe.tcpSocket.port
| string
| `"nats"`
|
| nats.resources.limits.cpu
| string
| `"100m"`
|
| nats.resources.limits.memory
| string
| `"128Mi"`
|
| nats.resources.requests.cpu
| string
| `"100m"`
|
| nats.resources.requests.memory
| string
| `"128Mi"`
|
| nats.service.port.mqtt
| int
| `1883`
|
| nats.service.port.nats
| int
| `4222`
|
| nodeSelector
| object
| `{}`
|
| persistence.accessMode
| string
| `"ReadWriteOnce"`
|
| persistence.annotations
| object
| `{}`
|
| persistence.enabled
| bool
| `false`
|
| persistence.existingClaim
| string
| `nil`
| A manually managed Persistent Volume and Claim Requires persistence.enabled: true If defined, PVC must be created manually before volume will be bound
| persistence.hostPath
| string
| `nil`
|
| persistence.size
| string
| `"1Gi"`
|
| persistence.storageClass
| string
| `nil`
| data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. (gp2 on AWS, standard on GKE, AWS & OpenStack)
| podAnnotations
| object
| `{}`
|
| podLabels
| object
| `{}`
|
| podSecurityContext
| object
| `{}`
|
| readinessProbe.httpGet.path
| string
| `"/"`
|
| readinessProbe.httpGet.port
| string
| `"http"`
|
| replicaCount
| int
| `1`
|
| resources
| object
| `{}`
|
| securityContext
| object
| `{}`
|
| service.port
| int
| `80`
|
| service.type
| string
| `"ClusterIP"`
|
| serviceAccount.annotations
| object
| `{}`
| Annotations to add to the service account
| serviceAccount.create
| bool
| `true`
| Specifies whether a service account should be created
| serviceAccount.name
| string
| `""`
| If not set and create is true, a name is generated using the fullname template
| tolerations
| list
| `[]`
|
| volumeMounts
| list
| `[]`
|
| volumes
| list
| `[]`
|
| zigbee2mqtt.config.homeassistant
| bool
| `true`
|
| zigbee2mqtt.config.serial.port
| string
| `"/dev/ttyACM0"`
|
| zigbee2mqtt.device
| string
| `"/dev/ttyACM0"`
|
| zigbee2mqtt.enabled
| bool
| `true`
|
| zigbee2mqtt.image.pullPolicy
| string
| `"IfNotPresent"`
|
| zigbee2mqtt.image.registry
| string
| `"docker.io"`
|
| zigbee2mqtt.image.repository
| string
| `"koenkk/zigbee2mqtt"`
|
| zigbee2mqtt.image.tag
| string
| `"1.36.0"`
|
| zigbee2mqtt.securityContext.privileged
| bool
| `true`
|
|===
Autogenerated from chart metadata using https://github.com/norwoodj/helm-docs[helm-docs]
= home-assistant
image::https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square[Version: 0.1.0]
image::https://img.shields.io/badge/Version-application-informational?style=flat-square[Type: application]
image::https://img.shields.io/badge/AppVersion-2024.3.1-informational?style=flat-square[AppVersion: 2024.3.1]
Home Assistant with tooling to run on an k3s pi
== Maintainers
.Maintainers
|===
| Name | Email | Url
| WrenIX
|
| <https://wrenix.eu>
|===
== Values
.Values
|===
| Key | Type | Default | Description
| affinity
| object
| `{}`
|
| autoscaling.enabled
| bool
| `false`
|
| autoscaling.maxReplicas
| int
| `100`
|
| autoscaling.minReplicas
| int
| `1`
|
| autoscaling.targetCPUUtilizationPercentage
| int
| `80`
|
| fullnameOverride
| string
| `""`
|
| global.image.pullPolicy
| string
| `nil`
| if set it will overwrite all pullPolicy
| global.image.registry
| string
| `nil`
| if set it will overwrite all registry entries
| image.pullPolicy
| string
| `"IfNotPresent"`
|
| image.registry
| string
| `"ghcr.io"`
|
| image.repository
| string
| `"home-assistant/home-assistant"`
|
| image.tag
| string
| `""`
|
| imagePullSecrets
| list
| `[]`
|
| ingress.annotations
| object
| `{}`
|
| ingress.className
| string
| `""`
|
| ingress.enabled
| bool
| `false`
|
| ingress.hosts[0].host
| string
| `"chart-example.local"`
|
| ingress.hosts[0].paths[0].path
| string
| `"/"`
|
| ingress.hosts[0].paths[0].pathType
| string
| `"ImplementationSpecific"`
|
| ingress.tls
| list
| `[]`
|
| livenessProbe.httpGet.path
| string
| `"/"`
|
| livenessProbe.httpGet.port
| string
| `"http"`
|
| nameOverride
| string
| `""`
|
| nats.enabled
| bool
| `true`
|
| nats.image.pullPolicy
| string
| `"IfNotPresent"`
|
| nats.image.registry
| string
| `"docker.io"`
|
| nats.image.repository
| string
| `"library/nats"`
|
| nats.image.tag
| string
| `"2.10.12-scratch"`
|
| nats.livenessProbe.tcpSocket.port
| string
| `"nats"`
|
| nats.readinessProbe.tcpSocket.port
| string
| `"nats"`
|
| nats.resources.limits.cpu
| string
| `"100m"`
|
| nats.resources.limits.memory
| string
| `"128Mi"`
|
| nats.resources.requests.cpu
| string
| `"100m"`
|
| nats.resources.requests.memory
| string
| `"128Mi"`
|
| nats.service.port.mqtt
| int
| `1883`
|
| nats.service.port.nats
| int
| `4222`
|
| nodeSelector
| object
| `{}`
|
| persistence.accessMode
| string
| `"ReadWriteOnce"`
|
| persistence.annotations
| object
| `{}`
|
| persistence.enabled
| bool
| `false`
|
| persistence.existingClaim
| string
| `nil`
| A manually managed Persistent Volume and Claim Requires persistence.enabled: true If defined, PVC must be created manually before volume will be bound
| persistence.hostPath
| string
| `nil`
|
| persistence.size
| string
| `"1Gi"`
|
| persistence.storageClass
| string
| `nil`
| data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. (gp2 on AWS, standard on GKE, AWS & OpenStack)
| podAnnotations
| object
| `{}`
|
| podLabels
| object
| `{}`
|
| podSecurityContext
| object
| `{}`
|
| readinessProbe.httpGet.path
| string
| `"/"`
|
| readinessProbe.httpGet.port
| string
| `"http"`
|
| replicaCount
| int
| `1`
|
| resources
| object
| `{}`
|
| securityContext
| object
| `{}`
|
| service.port
| int
| `80`
|
| service.type
| string
| `"ClusterIP"`
|
| serviceAccount.annotations
| object
| `{}`
| Annotations to add to the service account
| serviceAccount.create
| bool
| `true`
| Specifies whether a service account should be created
| serviceAccount.name
| string
| `""`
| If not set and create is true, a name is generated using the fullname template
| tolerations
| list
| `[]`
|
| volumeMounts
| list
| `[]`
|
| volumes
| list
| `[]`
|
| zigbee2mqtt.config.homeassistant
| bool
| `true`
|
| zigbee2mqtt.config.serial.port
| string
| `"/dev/ttyACM0"`
|
| zigbee2mqtt.device
| string
| `"/dev/ttyACM0"`
|
| zigbee2mqtt.enabled
| bool
| `true`
|
| zigbee2mqtt.image.pullPolicy
| string
| `"IfNotPresent"`
|
| zigbee2mqtt.image.registry
| string
| `"docker.io"`
|
| zigbee2mqtt.image.repository
| string
| `"koenkk/zigbee2mqtt"`
|
| zigbee2mqtt.image.tag
| string
| `"1.36.0"`
|
| zigbee2mqtt.securityContext.privileged
| bool
| `true`
|
|===
----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.2](https://github.com/norwoodj/helm-docs/releases/v1.11.2)

View file

@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- 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 "home-assistant.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 the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "home-assistant.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "home-assistant.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 "home-assistant.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 }}

View file

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "home-assistant.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "home-assistant.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "home-assistant.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "home-assistant.labels" -}}
helm.sh/chart: {{ include "home-assistant.chart" . }}
{{ include "home-assistant.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "home-assistant.selectorLabels" -}}
app.kubernetes.io/name: {{ include "home-assistant.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "home-assistant.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "home-assistant.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,86 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "home-assistant.fullname" . }}
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "home-assistant.selectorLabels" . | nindent 6 }}
type: main
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "home-assistant.labels" . | nindent 8 }}
type: main
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "home-assistant.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.image }}
image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }}
{{- end }}
ports:
- name: http
containerPort: 8123
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /config
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.persistence.enabled }}
- name: "data"
{{- if and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual" ) }}
hostPath:
path: {{ .Values.persistence.hostPath }}
{{- else }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "miniserve.fullname" . }}{{- end }}
{{- end }}
{{- end }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- 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 }}

View file

@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "home-assistant.fullname" . }}
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "home-assistant.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,42 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "home-assistant.fullname" . }}
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
{{- with .Values.ingress.tls }}
tls:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "home-assistant.fullname" $ }}
port:
name: http
{{- if $.Values.zigbee2mqtt }}
- path: /zigbee2mqtt
pathType: Prefix
backend:
service:
name: {{ include "home-assistant.fullname" $ }}-zigbee2mqtt
port:
name: http
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,17 @@
{{- if .Values.nats.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "home-assistant.fullname" . }}-nats
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
data:
server.conf: |-
port: 4222
jetstream {
store_dir: /var/lib/nats
}
mqtt {
port: 1883
}
{{- end }}

View file

@ -0,0 +1,102 @@
{{- if .Values.nats.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "home-assistant.fullname" . }}-nats
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "home-assistant.selectorLabels" . | nindent 6 }}
type: nats
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "home-assistant.labels" . | nindent 8 }}
type: nats
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "home-assistant.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.nats.image }}
image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag }}"
imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }}
{{- end }}
ports:
- name: nats
containerPort: 4222
protocol: TCP
- name: mqtt
containerPort: 1883
protocol: TCP
livenessProbe:
{{- toYaml .Values.nats.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.nats.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.nats.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /nats-server.conf
subPath: nats-server.conf
readOnly: true
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /var/lib/nats
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: "config"
configMap:
name: {{ include "home-assistant.fullname" . }}-nats
items:
- key: "server.conf"
path: "nats-server.conf"
{{- if .Values.persistence.enabled }}
- name: "data"
{{- if and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual" ) }}
hostPath:
path: {{ .Values.persistence.hostPath }}/nats/
{{- else }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "miniserve.fullname" . }}{{- end }}
{{- end }}
{{- end }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- 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 }}
{{- end }}

View file

@ -0,0 +1,22 @@
{{- if .Values.nats.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "home-assistant.fullname" . }}-nats
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "home-assistant.selectorLabels" . | nindent 4 }}
type: nats
ports:
- name: nats
port: {{ .Values.nats.service.port.nats }}
protocol: TCP
targetPort: nats
- name: mqtt
port: {{ .Values.nats.service.port.mqtt }}
protocol: TCP
targetPort: mqtt
{{- end }}

View file

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "home-assistant.fullname" . }}
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "home-assistant.selectorLabels" . | nindent 4 }}
type: main
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http

View file

@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "home-assistant.serviceAccountName" . }}
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "home-assistant.fullname" . }}-test-connection"
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "home-assistant.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View file

@ -0,0 +1,19 @@
{{- if .Values.zigbee2mqtt.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "home-assistant.fullname" . }}-zigbee2mqtt
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
data:
ZIGBEE2MQTT_CONFIG_MQTT_SERVER: {{ printf "mqtt://%s-nats:%v" (include "home-assistant.fullname" .) .Values.nats.service.port.mqtt }}
ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_OUTPUT: '["console"]'
{{- with .Values.zigbee2mqtt.config }}
{{- with .homeassistant }}
ZIGBEE2MQTT_CONFIG_HOMEASSISTANT: {{ . | quote }}
{{- end }}
{{- range $key, $value := .serial}}
ZIGBEE2MQTT_CONFIG_SERIAL_{{ $key | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,99 @@
{{- if .Values.zigbee2mqtt.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "home-assistant.fullname" . }}-zigbee2mqtt
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "home-assistant.selectorLabels" . | nindent 6 }}
type: zigbee2mqtt
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "home-assistant.labels" . | nindent 8 }}
type: zigbee2mqtt
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "home-assistant.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.zigbee2mqtt.securityContext | nindent 12 }}
{{- with .Values.zigbee2mqtt.image }}
image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag }}"
imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "home-assistant.fullname" . }}-zigbee2mqtt
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: device
mountPath: {{ .Values.zigbee2mqtt.config.serial.port }}
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /app/data
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: device
hostPath:
path: {{ .Values.zigbee2mqtt.device }}
{{- if .Values.persistence.enabled }}
- name: "data"
{{- if and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual" ) }}
hostPath:
path: {{ .Values.persistence.hostPath }}/zigbee2mqtt
{{- else }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "miniserve.fullname" . }}{{- end }}
{{- end }}
{{- end }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- 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 }}
{{- end }}

View file

@ -0,0 +1,18 @@
{{- if .Values.zigbee2mqtt.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "home-assistant.fullname" . }}-zigbee2mqtt
labels:
{{- include "home-assistant.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "home-assistant.selectorLabels" . | nindent 4 }}
type: zigbee2mqtt
ports:
- name: http
port: 8080
protocol: TCP
targetPort: http
{{- end }}

172
home-assistant/values.yaml Normal file
View file

@ -0,0 +1,172 @@
replicaCount: 1
global:
image:
# -- if set it will overwrite all registry entries
registry:
# -- if set it will overwrite all pullPolicy
pullPolicy:
image:
registry: ghcr.io
repository: home-assistant/home-assistant
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
nats:
enabled: true
image:
registry: docker.io
repository: library/nats
pullPolicy: IfNotPresent
tag: "2.10.12-scratch"
service:
port:
nats: 4222
mqtt: 1883
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
livenessProbe:
tcpSocket:
port: nats
readinessProbe:
tcpSocket:
port: nats
zigbee2mqtt:
enabled: true
image:
registry: docker.io
repository: koenkk/zigbee2mqtt
pullPolicy: IfNotPresent
tag: 1.36.0
device: /dev/ttyACM0
securityContext:
privileged: true
config:
homeassistant: true
serial:
port: /dev/ttyACM0
persistence:
enabled: false
annotations: {}
# -- data Persistent Volume Storage Class
# If defined, storageClassName: <storageClass>
# If set to "-", storageClassName: "", which disables dynamic provisioning
# If undefined (the default) or set to null, no storageClassName spec is
# set, choosing the default provisioner. (gp2 on AWS, standard on
# GKE, AWS & OpenStack)
#
storageClass:
# -- A manually managed Persistent Volume and Claim
# Requires persistence.enabled: true
# If defined, PVC must be created manually before volume will be bound
existingClaim:
## use container hostPatch or an PV if you set storageClass to manual
hostPath:
accessMode: ReadWriteOnce
size: 1Gi
serviceAccount:
# -- Specifies whether a service account should be created
create: true
# -- Annotations to add to the service account
annotations: {}
# -- The name of the service account to use.
# -- If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
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: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
# 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: {}