diff --git a/.woodpecker/zigbee2mqtt.yaml b/.woodpecker/zigbee2mqtt.yaml new file mode 100644 index 0000000..a4f758d --- /dev/null +++ b/.woodpecker/zigbee2mqtt.yaml @@ -0,0 +1,13 @@ +--- +when: + path: "charts/zigbee2mqtt/**" +branches: + - main +pipeline: + package: + image: "docker.io/alpine/helm:latest" + secrets: [helm_user, helm_password, helm_repo] + commands: + - helm plugin install https://github.com/chartmuseum/helm-push + - helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD + - helm cm-push charts/zigbee2mqtt therepo diff --git a/charts/zigbee2mqtt/.helmignore b/charts/zigbee2mqtt/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/zigbee2mqtt/.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/charts/zigbee2mqtt/Chart.yaml b/charts/zigbee2mqtt/Chart.yaml new file mode 100644 index 0000000..bedddaa --- /dev/null +++ b/charts/zigbee2mqtt/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: zigbee2mqtt +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/zigbee2mqtt/templates/_helpers.tpl b/charts/zigbee2mqtt/templates/_helpers.tpl new file mode 100644 index 0000000..c44c370 --- /dev/null +++ b/charts/zigbee2mqtt/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +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 }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "zigbee2mqtt.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "zigbee2mqtt.labels" -}} +helm.sh/chart: {{ include "zigbee2mqtt.chart" . }} +{{ include "zigbee2mqtt.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "zigbee2mqtt.selectorLabels" -}} +app.kubernetes.io/name: {{ include "zigbee2mqtt.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "zigbee2mqtt.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "zigbee2mqtt.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/zigbee2mqtt/templates/configmap.yaml b/charts/zigbee2mqtt/templates/configmap.yaml new file mode 100644 index 0000000..c999bd0 --- /dev/null +++ b/charts/zigbee2mqtt/templates/configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "zigbee2mqtt.fullname" . }}-confoverride + labels: + {{- include "zigbee2mqtt.labels" . | nindent 4 }} +data: + {{- if .Values.config.injectMqttAddress }} + ZIGBEE2MQTT_CONFIG_MQTT_SERVER: {{ .Values.injectMqttAddress }} + {{- end }} + {{- with .Values.config.timezone }} + TZ: {{ . | quote }} + {{- end }} + {{- list .Values.configOverride "ZIGBEE2MQTT_CONFIG" | include "recurseFlattenMap" | nindent 4 }} diff --git a/charts/zigbee2mqtt/templates/deployment.yaml b/charts/zigbee2mqtt/templates/deployment.yaml new file mode 100644 index 0000000..24facd2 --- /dev/null +++ b/charts/zigbee2mqtt/templates/deployment.yaml @@ -0,0 +1,93 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "zigbee2mqtt.fullname" . }}-zigbee2mqtt + labels: + {{- include "zigbee2mqtt.labels" . | nindent 4 }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + hass.kube.a09.uk/automationService: zigbee2mqtt + {{- include "zigbee2mqtt.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/zigbee2mqtt/configmap.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + hass.kube.a09.uk/automationService: zigbee2mqtt + {{- include "zigbee2mqtt.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "zigbee2mqtt.serviceAccountName" . }}-zigbee2mqtt + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + priorityClassName: {{ .Values.priorityClassName }} + containers: + - name: {{ .Chart.Name }}-zigbee2mqtt + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.configOverride.frontend }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + #startupProbe: + # httpGet: + # path: / + # port: http + # failureThreshold: 30 + #livenessProbe: + # httpGet: + # path: / + # port: http + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /app/data + - name: device + mountPath: /dev/ttyACM0 + envFrom: + - configMapRef: + name: {{ include "zigbee2mqtt.fullname" . }}-confoverride + securityContext: + privileged: true + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: data + persistentVolumeClaim: + {{- if not .Values.pvc.existingClaim }} + claimName: {{ include "zigbee2mqtt.fullname" . }}-zigbee2mqtt-data + {{- else }} + claimName: {{ .Values.pvc.existingClaim }} + {{- end }} + - name: device + hostPath: + path: {{ .Values.config.devicePath | quote }} + type: CharDevice diff --git a/charts/zigbee2mqtt/templates/ingress.yaml b/charts/zigbee2mqtt/templates/ingress.yaml new file mode 100644 index 0000000..63f0b91 --- /dev/null +++ b/charts/zigbee2mqtt/templates/ingress.yaml @@ -0,0 +1,24 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "zigbee2mqtt.fullname" . }}-zigbee2mqtt + labels: + {{- include "zigbee2mqtt.labels" . | nindent 4 }} + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" +spec: + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "zigbee2mqtt.fullname" . }} + port: + name: http +{{- end }} diff --git a/charts/zigbee2mqtt/templates/pvc.yaml b/charts/zigbee2mqtt/templates/pvc.yaml new file mode 100644 index 0000000..163fdc7 --- /dev/null +++ b/charts/zigbee2mqtt/templates/pvc.yaml @@ -0,0 +1,17 @@ +{{- if not .Values.pvc.existingClaim -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "zigbee2mqtt.fullname" . }}-zigbee2mqtt-data + labels: + {{- include "zigbee2mqtt.labels" . | nindent 4 }} + annotations: + helm.sh/resource-policy: "keep" +spec: + accessModes: + - ReadWriteOnce + storageClassName: {{ .Values.pvc.storageClassName | quote }} + resources: + requests: + storage: {{ .Values.pvc.storage | quote }} +{{- end }} diff --git a/charts/zigbee2mqtt/templates/service.yaml b/charts/zigbee2mqtt/templates/service.yaml new file mode 100644 index 0000000..536b0e3 --- /dev/null +++ b/charts/zigbee2mqtt/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "zigbee2mqtt.fullname" . }} + labels: + {{- include "zigbee2mqtt.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: 8080 + targetPort: http + protocol: TCP + name: http + {{- with .Values.service.nodePort }} + nodePort: {{ . }} + {{- end }} + selector: + {{- include "zigbee2mqtt.selectorLabels" . | nindent 4 }} + hass.kube.a09.uk/automationService: zigbee2mqtt diff --git a/charts/zigbee2mqtt/values.yaml b/charts/zigbee2mqtt/values.yaml new file mode 100644 index 0000000..c247a89 --- /dev/null +++ b/charts/zigbee2mqtt/values.yaml @@ -0,0 +1,61 @@ +# Default values for esphome. +# This is a YAML-formatted file. +image: + repository: docker.io/koenkk/zigbee2mqtt + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + host: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +pvc: + existingClaim: false + storageClassName: "" + storage: 1Gi + +config: + injectMqttAddress: false + devicePath: "" + timezone: Europe/London + +configOverride: + serial: + port: /dev/ttyACM0 + frontend: true