Skip to content

Commit e24a92a

Browse files
authored
Merge pull request #14 from small-hack/add-dconz-as-subchart
convert `homeAssistant.configuration` type to in-line yaml, add initial deconz chart, clean up home assistant values.yaml, add pre-commit
2 parents 89e9da1 + 6b4e9dc commit e24a92a

File tree

19 files changed

+716
-52
lines changed

19 files changed

+716
-52
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Helm
2828
uses: azure/[email protected]
2929
with:
30-
version: v3.11.1
30+
version: v3.14.3
3131

3232
- name: Run chart-releaser
3333
uses: helm/[email protected]

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/norwoodj/helm-docs
3+
rev: v1.13.1
4+
hooks:
5+
- id: helm-docs

README.md

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# home assistant helm chart
1+
# Home Assistant helm chart
22
<a href="https://github.com/small-hack/home-assistant-chart/releases"><img src="https://img.shields.io/github/v/release/small-hack/home-assistant-chart?style=plastic&labelColor=blue&color=green&logo=GitHub&logoColor=white"></a><br />
3-
Who doesn't need more home assistant helm charts?
3+
Who doesn't need more home assistant helm charts? This is a generic home assistant chart with basic features. It was written for use via [this Argo CD app](https://github.com/small-hack/argocd-apps/tree/main/home-assistant) which we deploy on metal with [`smol-k8s-lab`](https://github.com/small-hack/smol-k8s-lab).
44

55
#### Features
66

7-
- Put a default configuration.yaml in place of your choosing.
7+
- Put a default configuration.yaml in place of your choosing with either:
8+
- your own ConfigMap
9+
- specifying an in-line yaml string for us to render as a ConfigMap for you
810
- Kept up to date by RenovateBot
911

1012
## TLDR
@@ -20,17 +22,49 @@ helm show values home-assistant/home-assistant > values.yaml
2022
helm install --namespace home-assistant --create-namespace home-assistant/home-assistant --values values.yaml
2123
```
2224

23-
## tips
25+
## Tips
2426

25-
### Using your own configuration.yaml
2627

27-
make sure your ConfigMap has a key called `configuration.yaml` with in-line yaml data like this:
28+
### Unit system, Temp Unit, and Time Zone
29+
30+
```yaml
31+
homeAssistant:
32+
configuration: |
33+
homeassistant:
34+
time_zone: Europe/Amsterdam
35+
temperature_unit: C
36+
unit_system: metric
37+
```
38+
39+
### Making Ingress Nginx work for public domains
40+
41+
I had to add the IP range of the k8s cluster to my trusted proxies in my home assistant `configuration.yaml` (also since this was public, I needed to declare an `external_url`).
42+
This is what I added to my `values.yaml` to do that through this chart:
43+
44+
```yaml
45+
homeAssistant:
46+
configuration: |
47+
# this sets your extenral url
48+
homeassistant:
49+
external_url: 'https://iot.examplesforgooddogs.com'
50+
51+
# this enables proxies such as the ingress nginx controller
52+
http:
53+
use_x_forwarded_for: true
54+
trusted_proxies:
55+
- 10.0.0.0/8
56+
```
57+
58+
59+
### Using an existing ConfigMap for configuration.yaml
60+
61+
For the ConfigMap, make sure your ConfigMap has a key called `configuration.yaml` with in-line yaml data like this:
2862

2963
```yaml
3064
apiVersion: v1
3165
kind: ConfigMap
3266
metadata:
33-
name: home-assistant
67+
name: my-home-assistant-configmap
3468
namespace: home-assistant
3569
data:
3670
configuration.yaml: |
@@ -40,10 +74,25 @@ data:
4074
use_x_forwarded_for: true
4175
```
4276

77+
Then, you'd specify the name of your ConfigMap in your `values.yaml` like this:
4378

44-
### External Devices
79+
```yaml
80+
homeAssistant:
81+
existingConfigMap: "my-home-assistant-configmap"
82+
```
83+
84+
85+
### USB Devices
86+
87+
If you're on metal, make sure your device is accessible, which in the case of a USB device e.g. conbee II, will require you to install the [generic device plugin](https://github.com/squat/generic-device-plugin):
88+
89+
```bash
90+
kubectl apply -f https://raw.githubusercontent.com/squat/generic-device-plugin/main/manifests/generic-device-plugin.yaml
91+
```
92+
93+
#### Values.yaml
4594

46-
tip from pajikos/home-assistant for passing in usb devices via values.yaml:
95+
Tip from [pajikos/home-assistant](https://github.com/pajikos/home-assistant) for passing in USB devices via `values.yaml`:
4796

4897
```yaml
4998
volumes:
@@ -58,5 +107,16 @@ volumeMounts:
58107
name: usb
59108
```
60109

61-
## status
62-
demo and toy. feel free to submit PRs and Issues
110+
### Mobile config
111+
112+
If you're new to home assistant, you may be wondering how you connect to the companion app on your phone. This requires you to put a key with no value called `mobile:` in the `configuration.yaml`. This would break your values.yaml depending on the gitops solution you're using, so we take the configuration as an in-line yaml block string instead like this:
113+
114+
```yaml
115+
homeAssistant:
116+
configuration: |
117+
# this has no value
118+
mobile:
119+
```
120+
121+
## Status
122+
Seemingly stable. Feel free to submit PRs and Issues though :)

charts/deconz/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/deconz/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: deconz
3+
description: A Helm chart for deconz on Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "2.26.1"

charts/deconz/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# deconz
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.26.1](https://img.shields.io/badge/AppVersion-2.26.1-informational?style=flat-square)
4+
5+
A Helm chart for deconz on Kubernetes
6+
7+
## Values
8+
9+
| Key | Type | Default | Description |
10+
|-----|------|---------|-------------|
11+
| affinity | object | `{}` | affinity for the pod e.g. to attract it to a specific node in the cluster nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: 'usb' operator: In values: - 'true' |
12+
| autoscaling.enabled | bool | `false` | |
13+
| autoscaling.maxReplicas | int | `100` | |
14+
| autoscaling.minReplicas | int | `1` | |
15+
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
16+
| deconz.devicePath | string | `"/dev/ttyACM0"` | Override the location where deCONZ looks for the RaspBee/Conbee device. Becomes DECONZ_DEVICE: "" Examples: /dev/ttyUSB0 (conbee1), /dev/ttyACM0 (conbee2) |
17+
| deconz.gid | string | `"0"` | GID for the container user, becomes DECONZ_GID in the env vars |
18+
| deconz.startVerbose | int | `1` | becomes DECONZ_START_VERBOSE. set to 0 to turn off extra logging |
19+
| deconz.timeZone | string | `"Europe/Amsterdam"` | becomes TZ env var. this is the timezone |
20+
| deconz.uid | string | `"0"` | UID for the container user, becomes DECONZ_UID in the env vars |
21+
| deconz.webPort | string | `"8080"` | becomes DECONZ_WEB_PORT in env vars. |
22+
| deconz.wsPort | string | `"8443"` | becomes DECONZ_WS_PORT. may be useful to set to: "10001" |
23+
| extraEnv | object | `{}` | extra environment variables you want to pass to the deconz pod |
24+
| fullnameOverride | string | `""` | |
25+
| image.pullPolicy | string | `"IfNotPresent"` | |
26+
| image.repository | string | `"deconzcommunity/deconz"` | |
27+
| image.tag | string | `""` | |
28+
| imagePullSecrets | list | `[]` | |
29+
| ingress.annotations | object | `{}` | |
30+
| ingress.className | string | `"nginx"` | |
31+
| ingress.enabled | bool | `false` | |
32+
| ingress.hosts[0].host | string | `"chart-example.local"` | |
33+
| ingress.hosts[0].paths[0].path | string | `"/"` | |
34+
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
35+
| ingress.tls | list | `[]` | |
36+
| livenessProbe.httpGet.path | string | `"/"` | |
37+
| livenessProbe.httpGet.port | string | `"http"` | |
38+
| nameOverride | string | `""` | |
39+
| nodeSelector | object | `{}` | |
40+
| podAnnotations | object | `{}` | |
41+
| podLabels | object | `{}` | |
42+
| podSecurityContext | object | `{}` | |
43+
| readinessProbe.httpGet.path | string | `"/"` | |
44+
| readinessProbe.httpGet.port | string | `"http"` | |
45+
| replicaCount | int | `1` | |
46+
| resources | object | `{}` | |
47+
| securityContext.capabilities.add[0] | string | `"NET_BIND_SERVICE"` | |
48+
| service.port | int | `80` | |
49+
| service.type | string | `"ClusterIP"` | |
50+
| serviceAccount.annotations | object | `{}` | |
51+
| serviceAccount.automount | bool | `true` | |
52+
| serviceAccount.create | bool | `true` | |
53+
| serviceAccount.name | string | `""` | |
54+
| tolerations | list | `[]` | tolerations for tainted nodes, example: - key: usb operator: Equal value: true effect: NoSchedule |
55+
| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition. exmaple: - mountPath: /dev/ttyACM0 name: usb |
56+
| volumes | list | `[]` | Additional volumes on the output Deployment definition. example: - hostPath: path: >- /dev/serial/... type: CharDevice name: usb |
57+
58+
----------------------------------------------
59+
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)

charts/deconz/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dconz.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dconz.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dconz.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dconz.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "dconz.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "dconz.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "dconz.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "dconz.labels" -}}
37+
helm.sh/chart: {{ include "dconz.chart" . }}
38+
{{ include "dconz.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "dconz.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "dconz.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "dconz.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "dconz.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)