Skip to content

Commit

Permalink
fix: Add Helm chart (#21852)
Browse files Browse the repository at this point in the history
* Initial draft for helm chart

* Add CI using helm releaser

Add helm chart docummentation

Add configuration.yaml values

* Set maintainer

set right defaults on values.yaml

* Add ci to update values on chart

* Add chart version on CI

* Remove manual update of the chart

* Trigger update of Chart.yaml with release_please

* Add chart to release-please

* Add version to release-please manifest for chart

* remove the second release-please

* Update appVersion in chart.yaml too

* Add make target to generate helm-docs

* Generate docs and manage versions in release-please

* Add persistent static volumes

* Small fixes, ensure no volume works

* Fixes for static provisioned volume

* Delete yq dependency in CI

* Delete Makefile, update release-please to run doc generation directly

---------

Co-authored-by: jose <jose.pedrosa@reddit.com>
  • Loading branch information
jlpedrosa and jlpedrosaSnoo committed May 6, 2024
1 parent 358e2ee commit b2e8b3e
Show file tree
Hide file tree
Showing 14 changed files with 666 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/helm_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Charts

on:
push:
branches:
- main
paths:
- 'charts/**'

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
skip_existing: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
33 changes: 33 additions & 0 deletions .github/workflows/release_please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ jobs:
target-branch: dev
token: ${{secrets.GH_TOKEN}}

# we use grep,awk,sed here because the output from release-please despite being JSON, it's not valid (probably shell-escaping) and
# jq fails to parse it. Creates the output pr_branch
- name: Get the branch of the release-please PR
id: get_pr_branch
if: ${{ steps.release.outputs.prs_created == 'true' }}
run: |
BRANCH=$(echo '${{ steps.release.outputs.prs }}' | grep -o -P '\"headBranchName\":\"(.*?)\"' | awk -F':' '{print $2}' | tr -d \")
echo "pr_branch=${BRANCH}" >> $GITHUB_OUTPUT
# Checkout PR branch
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.prs_created == 'true' }}
with:
repository: koenkk/zigbee2mqtt
path: ./z2m-pr
ref: ${{ steps.get_pr_branch.outputs.pr_branch }}

- name: Add updated helm chart release versions and documentation to release PR
if: ${{ steps.release.outputs.prs_created == 'true' }}
run: |
pushd ./z2m-pr
Z2M_VERSION="$(jq -r '."."' .release-please-manifest.json)"
yq -i ".appVersion=\"${Z2M_VERSION}\"" charts/zigbee2mqtt/Chart.yaml
yq -i ".image.tag=\"${Z2M_VERSION}\"" charts/zigbee2mqtt/values.yaml
# Keep chart version in step lock with zigbee2mqtt
jq ".\"charts/zigbee2mqtt\"=\"${Z2M_VERSION}\"" .release-please-manifest.json > .release-please-manifest.json
go run github.com/norwoodj/helm-docs/cmd/helm-docs@latest
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "chore(release): update helm-chart docs"
git push
# Checkout repos
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
".": "1.37.0"
".": "1.37.0",
"charts/zigbee2mqtt": "1.37.0"
}
23 changes: 23 additions & 0 deletions charts/zigbee2mqtt/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
Empty file added charts/zigbee2mqtt/CHANGELOG.md
Empty file.
17 changes: 17 additions & 0 deletions charts/zigbee2mqtt/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
appVersion: 1.37.0
description: Bridges events and allows you to control your Zigbee devices via MQTT
name: zigbee2mqtt
version: 1.37.0
kubeVersion: ">=1.26.0-0"
keywords:
- zigbee
- mqtt
- home-assistant
home: https://github.com/Koenkk/zigbee2mqtt
icon: https://www.zigbee2mqtt.io/logo.png
sources:
- https://github.com/Koenkk/zigbee2mqtt
maintainers:
- name: Koen Kanters
email: XXXX
92 changes: 92 additions & 0 deletions charts/zigbee2mqtt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# zigbee2mqtt

![Version: 1.37.0](https://img.shields.io/badge/Version-1.37.0-informational?style=flat-square) ![AppVersion: 1.37.0](https://img.shields.io/badge/AppVersion-1.37.0-informational?style=flat-square)

Bridges events and allows you to control your Zigbee devices via MQTT

**Homepage:** <https://github.com/Koenkk/zigbee2mqtt>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Koen Kanters | <XXXX> | |

## Source Code

* <https://github.com/Koenkk/zigbee2mqtt>

## Requirements

Kubernetes: `>=1.26.0-0`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| customLabels | object | `{}` | |
| fullnameOverride | string | `nil` | override the name of the objects generated |
| image.imagePullSecrets | object | `{}` | Container additional secrets to pull image |
| image.pullPolicy | string | `"IfNotPresent"` | Container pull policy |
| image.repository | string | `"koenkk/zigbee2mqtt"` | Image repository for the `zigbee2mqtt` container. |
| image.tag | string | `"33"` | Version for the `zigbee2mqtt` container. |
| ingress.annotations | object | `{}` | |
| ingress.enabled | bool | `true` | When enabled a new Ingress will be created |
| ingress.hosts[0] | string | `"yourdomain.com"` | |
| ingress.ingressClassName | string | `"contour"` | |
| ingress.labels | object | `{}` | |
| ingress.path | string | `"/"` | |
| ingress.pathType | string | `"Prefix"` | |
| ingress.tls[0].hosts[0] | string | `"yourdomain.com"` | |
| ingress.tls[0].secretName | string | `"some-tls-secret"` | |
| nameOverride | string | `nil` | override the release name |
| service.annotations | object | `{}` | annotations for the service created |
| service.port | int | `8080` | port in which the service will be listening |
| service.type | string | `"LoadBalancer"` | type of Service to be created |
| statefulset.dnsPolicy | string | `"ClusterFirst"` | pod dns policy |
| statefulset.nodeSelector | object | `{}` | Select specific kube node, this will allow enforcing zigbee2mqtt running only on the node with the USB adapter connected |
| statefulset.resources | object | `{"limits":{"cpu":"200m","memory":"600Mi"},"requests":{"cpu":"200m","memory":"600Mi"}}` | CPU/Memory configuration for the pods |
| statefulset.storage.storageClassName | string | `"nfs-csi"` | the name for the storage class to be used in the persistent volume claim |
| statefulset.tolerations | object | `{}` | Node taint tolerations for the pods |
| zigbee2mqtt.advanced.adapter_concurrent | string | `nil` | Optional: configure adapter concurrency (e.g. 2 for CC2531 or 16 for CC26X2R1) (default: null, uses recommended value) |
| zigbee2mqtt.advanced.adapter_delay | int | `0` | Optional: Set the adapter delay, only used for Conbee/Raspbee adapters (default 0). In case you are having issues try `200`. For more information see https://github.com/Koenkk/zigbee2mqtt/issues/4884 |
| zigbee2mqtt.advanced.cache_state | bool | `true` | Has to be true when integrating via Home Assistant (default: true) |
| zigbee2mqtt.advanced.cache_state_persistent | bool | `true` | Optional: persist cached state, only used when cache_state: true (default: true) |
| zigbee2mqtt.advanced.cache_state_send_on_startup | bool | `true` | Optional: send cached state on startup, only used when cache_state_persistent: true (default: true) |
| zigbee2mqtt.advanced.channel | int | `11` | Optional: ZigBee channel, changing requires re-pairing of all devices. (Note: use a ZLL channel: 11, 15, 20, or 25 to avoid Problems) (default: 11) |
| zigbee2mqtt.advanced.elapsed | bool | `false` | Optional: Add an elapsed attribute to MQTT messages, contains milliseconds since the previous msg (default: false) |
| zigbee2mqtt.advanced.ext_pan_id | string | `nil` | |
| zigbee2mqtt.advanced.last_seen | string | `"disable"` | Optional: Add a last_seen attribute to MQTT messages, contains date/time of last Zigbee message possible values are: disable (default), ISO_8601, ISO_8601_local, epoch (default: disable) |
| zigbee2mqtt.advanced.legacy_api | bool | `false` | Optional: disables the legacy api (default: shown below) |
| zigbee2mqtt.advanced.log_level | string | `"info"` | |
| zigbee2mqtt.advanced.log_output[0] | string | `"console"` | |
| zigbee2mqtt.advanced.network_key | string | `nil` | Optional: network encryption key GENERATE will make Zigbee2MQTT generate a new network key on next startup Note: changing requires repairing of all devices (default: shown below) |
| zigbee2mqtt.advanced.pan_id | string | `nil` | Optional: ZigBee pan ID (default: shown below) Setting pan_id: GENERATE will make Zigbee2MQTT generate a new panID on next startup |
| zigbee2mqtt.advanced.report | bool | `true` | Optional: Enables report feature, this feature is DEPRECATED since reporting is now setup by default when binding devices. Docs can still be found here: https://github.com/Koenkk/zigbee2mqtt.io/blob/master/docs/information/report.md |
| zigbee2mqtt.advanced.timestamp_format | string | `"YYYY-MM-DD HH:mm:ss"` | |
| zigbee2mqtt.advanced.transmit_power | int | `5` | Optional: Transmit power setting in dBm (default: 5). This will set the transmit power for devices that bring an inbuilt amplifier. It can't go over the maximum of the respective hardware and might be limited by firmware (for example to migrate heat, or by using an unsupported firmware). For the CC2652R(B) this is 5 dBm, CC2652P/CC1352P-2 20 dBm. |
| zigbee2mqtt.availability.active.timeout | int | `10` | Time after which an active device will be marked as offline in minutes (default = 10 minutes) |
| zigbee2mqtt.availability.passive.timeout | int | `1500` | Time after which a passive device will be marked as offline in minutes (default = 1500 minutes aka 25 hours) |
| zigbee2mqtt.external_converters | list | `[]` | |
| zigbee2mqtt.frontend.auth_token | string | `nil` | Optional, enables authentication, disabled by default, cleartext (no hashing required) |
| zigbee2mqtt.frontend.host | string | `"0.0.0.0"` | Optional, empty by default to listen on both IPv4 and IPv6. Opens a unix socket when given a path instead of an address (e.g. '/run/zigbee2mqtt/zigbee2mqtt.sock') Don't set this if you use Docker or the Home Assistant add-on unless you're sure the chosen IP is available inside the container |
| zigbee2mqtt.frontend.port | int | `8080` | Mandatory, default 8080 |
| zigbee2mqtt.frontend.url | string | `nil` | Optional, url on which the frontend can be reached, currently only used for the Home Assistant device configuration page |
| zigbee2mqtt.homeassistant.discovery_topic | string | `"homeassistant"` | |
| zigbee2mqtt.homeassistant.enabled | bool | `true` | |
| zigbee2mqtt.homeassistant.legacy_entity_attributes | bool | `true` | |
| zigbee2mqtt.homeassistant.legacy_triggers | bool | `false` | |
| zigbee2mqtt.homeassistant.status_topic | string | `"hass/status"` | |
| zigbee2mqtt.mqtt.server | string | `"mqtt://localhost:1883"` | Required: MQTT server URL (use mqtts:// for SSL/TLS connection) |
| zigbee2mqtt.ota | object | `{"disable_automatic_update_check":false,"ikea_ota_use_test_url":false,"update_check_interval":1440}` | Optional: OTA update settings See https://www.zigbee2mqtt.io/guide/usage/ota_updates.html for more info |
| zigbee2mqtt.ota.disable_automatic_update_check | bool | `false` | Disable automatic update checks |
| zigbee2mqtt.ota.ikea_ota_use_test_url | bool | `false` | Optional: use IKEA TRADFRI OTA test server, see OTA updates documentation (default: false) |
| zigbee2mqtt.ota.update_check_interval | int | `1440` | Minimum time between OTA update checks |
| zigbee2mqtt.permit_join | bool | `false` | Optional: allow new devices to join. |
| zigbee2mqtt.serial.adapter | string | `nil` | Optional: adapter type, not needed unless you are experiencing problems (default: shown below, options: zstack, deconz, ezsp) |
| zigbee2mqtt.serial.baudrate | int | `115200` | Optional: Baud rate speed for serial port, this can be anything firmware support but default is 115200 for Z-Stack and EZSP, 38400 for Deconz, however note that some EZSP firmware need 57600. |
| zigbee2mqtt.serial.disable_led | bool | `false` | Optional: disable LED of the adapter if supported (default: false) |
| zigbee2mqtt.serial.port | string | `"/dev/ttyACM0"` | Required: location of the adapter (e.g. CC2531). USB adapters - use format "port: /dev/ttyACM0" To autodetect the USB port, set 'port: null'. Ethernet adapters - use format "port: tcp://192.168.1.12:6638" |
| zigbee2mqtt.serial.rtscts | bool | `false` | Optional: RTS / CTS Hardware Flow Control for serial port (default: false) |
| zigbee2mqtt.timezone | string | `"UTC"` | |

37 changes: 37 additions & 0 deletions charts/zigbee2mqtt/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{/* vim: set filetype=mustache: */}}

{{/* Expand the name of the chart.*/}}
{{- define "zigbee2mqtt.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 "zigbee2mqtt.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 }}


{{/* labels for helm resources */}}
{{- define "zigbee2mqtt.labels" -}}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
app.kubernetes.io/name: "{{ template "zigbee2mqtt.name" . }}"
app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 2 -}}
{{- end }}
{{- end }}
39 changes: 39 additions & 0 deletions charts/zigbee2mqtt/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "zigbee2mqtt.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "zigbee2mqtt.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
configuration.yaml: |
# Define the files which contains the configs. As k8s config maps
# Are read only by design, we need to extract dynamic config to external files
devices: devices.yaml
groups: groups.yaml
{{- if .Values.zigbee2mqtt.homeassistant }}
homeassistant:
{{- .Values.zigbee2mqtt.homeassistant | toYaml | nindent 6}}
{{- end }}
ota:
{{- .Values.zigbee2mqtt.ota | toYaml | nindent 6}}
permit_join: {{ .Values.zigbee2mqtt.permit_join }}
{{- if .Values.zigbee2mqtt.availability }}
availability:
{{- .Values.zigbee2mqtt.availability | toYaml | nindent 6}}
{{- end }}
{{- if gt (len .Values.zigbee2mqtt.external_converters) 0 }}
external_converters: {{- .Values.zigbee2mqtt.external_converters }}
{{- end }}
mqtt:
{{- .Values.zigbee2mqtt.mqtt | toYaml | nindent 6}}
serial:
{{- .Values.zigbee2mqtt.serial | toYaml | nindent 6}}
frontend:
{{- .Values.zigbee2mqtt.frontend | toYaml | nindent 6}}
advanced:
{{- .Values.zigbee2mqtt.advanced | toYaml | nindent 6}}
56 changes: 56 additions & 0 deletions charts/zigbee2mqtt/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- if .Values.ingress.enabled -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $ingressPathType := .Values.ingress.pathType -}}
{{- $fullName := include "zigbee2mqtt.fullname" . }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "zigbee2mqtt.labels" . | nindent 4 }}
{{- with .Values.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- with .Values.ingress.tls }}
tls:
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
rules:
{{- if .Values.ingress.hosts }}
{{- range .Values.ingress.hosts }}
- host: {{ tpl . $ | quote }}
http:
paths:
- path: {{ $ingressPath }}
pathType: {{ $ingressPathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- end }}
{{- else }}
- http:
paths:
- backend:
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- with $ingressPath }}
path: {{ . }}
{{- end }}
pathType: {{ $ingressPathType }}

{{- end -}}
{{- end }}
20 changes: 20 additions & 0 deletions charts/zigbee2mqtt/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "zigbee2mqtt.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "zigbee2mqtt.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
selector:
app: {{ include "zigbee2mqtt.fullname" . }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: web
protocol: TCP
Loading

0 comments on commit b2e8b3e

Please sign in to comment.