diff --git a/charts/zigbee2mqtt/Chart.yaml b/charts/zigbee2mqtt/Chart.yaml new file mode 100644 index 0000000..f2a24e6 --- /dev/null +++ b/charts/zigbee2mqtt/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +appVersion: 1.35.3 +description: Zigbee Bridge via MQTT +name: zigbee2mqtt +version: 0.0.1 +type: application +keywords: + - zigbee2mqtt + - zigbee + - mqtt +home: https://github.com/JacekZubielik/jz-helm-charts/tree/master/charts/zigbee2mqtt +icon: https://www.zigbee2mqtt.io/images/logo.png +sources: + - https://github.com/Koenkk/zigbee2mqtt +maintainers: + - name: jacekzubielik diff --git a/charts/zigbee2mqtt/ci/ci-values.yaml b/charts/zigbee2mqtt/ci/ci-values.yaml new file mode 100644 index 0000000..4d278e9 --- /dev/null +++ b/charts/zigbee2mqtt/ci/ci-values.yaml @@ -0,0 +1,2 @@ +provider: + name: inmemory diff --git a/charts/zigbee2mqtt/templates/_helpers.tpl b/charts/zigbee2mqtt/templates/_helpers.tpl new file mode 100644 index 0000000..6aa4e06 --- /dev/null +++ b/charts/zigbee2mqtt/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* Expand the name of the chart. */}} +{{- define "app.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 "app.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 "app.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end -}} + +{{/* Common labels */}} +{{- define "app.labels" -}} +helm.sh/chart: {{ include "app.chart" . }} + +{{ include "app.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* Selector labels */}} +{{- define "app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "app.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* Create the name of the service account to use */}} +{{- define "app.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "app.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/zigbee2mqtt/templates/service.yaml b/charts/zigbee2mqtt/templates/service.yaml new file mode 100644 index 0000000..655ff2b --- /dev/null +++ b/charts/zigbee2mqtt/templates/service.yaml @@ -0,0 +1,41 @@ +apiVersion: v1 +kind: Service +metadata: + {{- if .Values.service.annotations }} + annotations: + {{- toYaml .Values.service.annotations | nindent 4 }} + {{- end }} + name: {{ template "app.fullname" . }} + labels: + {{- include "app.labels" . | nindent 4 }} + {{- if .Values.service.labels }} + {{ toYaml .Values.service.labels | indent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + {{- if .Values.service.externalIPs }} + externalIPs: + {{- toYaml .Values.service.externalIPs | nindent 4 }} + {{- end }} + {{- if .Values.service.externalTrafficPolicy }} + externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} + {{- end }} + {{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} + {{- end }} + {{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }} + {{- end }} + publishNotReadyAddresses: {{ .Values.service.publishNotReadyAddresses }} + ports: + - name: http + port: {{ .Values.service.httpPort }} + protocol: TCP + targetPort: {{ .Values.service.httpPort }} + - name: metrics + port: {{ .Values.service.metricsPort }} + protocol: TCP + targetPort: {{ .Values.service.metricsPort }} + selector: + {{- include "app.selectorLabels" . | nindent 4 }} diff --git a/charts/zigbee2mqtt/templates/serviceaccount.yaml b/charts/zigbee2mqtt/templates/serviceaccount.yaml new file mode 100644 index 0000000..13a3866 --- /dev/null +++ b/charts/zigbee2mqtt/templates/serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + {{- if .Values.serviceAccount.annotations }} + annotations: + {{- toYaml .Values.serviceAccount.annotations | nindent 4 }} + {{- end }} + name: {{ template "app.fullname" . }} + labels: + {{- include "app.labels" . | nindent 4 }} + {{- if .Values.serviceAccount.labels }} + {{ toYaml .Values.serviceAccount.labels | indent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} +{{- end }} diff --git a/charts/zigbee2mqtt/templates/servicemonitor.yaml b/charts/zigbee2mqtt/templates/servicemonitor.yaml new file mode 100644 index 0000000..eeecbad --- /dev/null +++ b/charts/zigbee2mqtt/templates/servicemonitor.yaml @@ -0,0 +1,64 @@ +{{- if and ( .Values.monitoring.serviceMonitor.enabled ) ( .Values.monitoring.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + {{- if .Values.monitoring.serviceMonitor.annotations }} + annotations: + {{- toYaml .Values.monitoring.serviceMonitor.annotations | nindent 4 }} + {{- end }} + name: {{ template "app.fullname" . }} + labels: + {{- include "app.labels" . | nindent 4 }} + {{- with .Values.monitoring.serviceMonitor.selector }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "app.selectorLabels" . | nindent 6 }} + {{- if .Values.podLabels }} + {{- toYaml .Values.podLabels | nindent 6 }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + - targetPort: {{ .Values.service.metricsPort }} + path: /metrics + {{- with .Values.monitoring.serviceMonitor.honorLabels }} + honorLabels: {{ . }} + {{- end }} + {{- if .Values.monitoring.serviceMonitor.interval }} + interval: {{ .Values.monitoring.serviceMonitor.interval }} + {{- end }} + {{- if .Values.monitoring.serviceMonitor.scrapeTimeout}} + scrapeTimeout: {{ .Values.monitoring.serviceMonitor.scrapeTimeout }} + {{- end }} + {{- with .Values.monitoring.serviceMonitor.scheme }} + scheme: {{ . }} + {{- end }} + {{- with .Values.monitoring.serviceMonitor.tlsConfig }} + tlsConfig: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.monitoring.serviceMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.monitoring.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- if .Values.monitoring.serviceMonitor.bearerTokenFile }} + bearerTokenFile: {{ .Values.monitoring.serviceMonitor.bearerTokenFile }} + {{- end }} + {{- if .Values.monitoring.serviceMonitor.bearerTokenSecret }} + bearerTokenSecret: + name: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.name }} + key: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.key }} + {{- if .Values.monitoring.serviceMonitor.bearerTokenSecret.optional }} + optional: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.optional }} + {{- end }} + {{- end }} + jobLabel: {{ template "app.fullname" . }} +{{- end }} diff --git a/charts/zigbee2mqtt/templates/statefullset.yaml b/charts/zigbee2mqtt/templates/statefullset.yaml new file mode 100644 index 0000000..9293c78 --- /dev/null +++ b/charts/zigbee2mqtt/templates/statefullset.yaml @@ -0,0 +1,151 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ template "app.fullname" . }} + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicas }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} + selector: + matchLabels: + {{- include "app.selectorLabels" . | nindent 6 }} + serviceName: {{ include "app.fullname" . }} + updateStrategy: {{ toYaml .Values.updateStrategy | nindent 4 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "app.selectorLabels" . | nindent 8 }} + {{- if .Values.podLabels }} + {{- toYaml .Values.podLabels | nindent 8 }} + {{- end }} + spec: + {{- with .Values.image.PullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} + shareProcessNamespace: {{ .Values.sidecarSingleProcessNamespace }} + serviceAccountName: {{ include "app.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 8 }} + {{- if .Values.hostNetwork }} + hostNetwork: {{ .Values.hostNetwork }} + dnsPolicy: ClusterFirstWithHostNet + {{- end }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: +{{/* Common labels + - name: TZ + value: {{ .Values.timezone }} +*/}} + - name: ZIGBEE2MQTT_DATA + value: "/data" + {{- if .Values.debug }} + - name: DEBUG + value: {{ .Values.debug }} + {{- end }} + {{- range $key, $value := .Values.extraEnv }} + - name: {{ $key | }} + value: {{ $value | }} + {{- end }} + {{- range $name, $opts := .Values.extraEnvSecrets }} + - name: {{ $name }} + valueFrom: + secretKeyRef: + name: {{ $opts.secret }} + key: {{ $opts.key }} + {{- end }} + envFrom: + {{- range .Values.extraSecretForEnvFrom }} + - secretRef: + name: {{ . }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + ports: + - name: http + containerPort: {{ .Values.service.httpPort }} + protocol: TCP + - name: metrics + containerPort: {{ .Values.service.metricsPort }} + protocol: TCP + {{- if .Values.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: http + scheme: {{ .Values.livenessProbe.scheme }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds}} + {{- end }} + {{- if .Values.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: / + port: http + scheme: {{ .Values.readinessProbe.scheme }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds}} + {{- end }} + volumeMounts: + - name: config-storage + mountPath: /data + {{- range .Values.hostMounts }} + {{- if .mountPath }} + - mountPath: {{ .mountPath }} + {{- else }} + - mountPath: {{ .hostPath }} + {{- end }} + name: {{ .name }} + {{- 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 }} + volumes: + - name: config-storage + {{- if .Values.persistence.enabled }} + {{- if .Values.persistence.configstorage.hostPath }} + hostPath: + path: {{.Values.persistence.configstorage.hostPath}} + {{- else }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "app.fullname" . }}{{- end }} + {{- end }} + {{- else }} + emptyDir: {} + {{ end }} + {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }} + - name: config-storage + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim }} + {{- end }} + {{- range .Values.hostMounts }} + - name: {{ .name }} + hostPath: + path: {{.hostPath}} + {{- end }} diff --git a/charts/zigbee2mqtt/values.yaml b/charts/zigbee2mqtt/values.yaml new file mode 100644 index 0000000..bd99db1 --- /dev/null +++ b/charts/zigbee2mqtt/values.yaml @@ -0,0 +1,176 @@ +image: + repository: koenkk/zigbee2mqtt + tag: "" + pullPolicy: IfNotPresent + pullSecrets: [] + +nameOverride: "" +fullnameOverride: "" +revisionHistoryLimit: 4 +hostNetwork: false + +replicas: 1 +updateStrategy: + type: RollingUpdate + # rollingUpdate: + # maxUnavailable: 0 + # maxSurge: 1 + +serviceAccount: + create: true + annotations: {} + automountServiceAccountToken: false + +podAnnotations: {} +podLabels: {} + +extraEnv: {} + +extraEnvSecrets: + # This will set ${MQTT_PASSWORD} to the 'password' key from the 'mqtt' secret + # MQTT_PASSWORD: + # secret: mqtt + # key: password + +## If you'd like to provide your own Kubernetes Secret object instead of passing your values +## individually, pass in the name of a created + populated Secret. +## All secrets will be mounted as environment variables, with each key/value mapping to a +## corresponding environment variable. +extraSecretForEnvFrom: [] +# - zigbee2mqtt-secrets + +podSecurityContext: + privileged: true + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + annotations: + prometheus.io/scrape: "false" + prometheus.io/port: 9100 + labels: {} + type: ClusterIP + externalIPs: [] + loadBalancerIP: "" + externalTrafficPolicy: {} + loadBalancerSourceRanges: [] + publishNotReadyAddresses: false + httpPort: "8080" + metricsPort: "9100" +monitoring: + enabled: false + serviceMonitor: + enabled: false + annotations: + prometheus.io/scrape: "false" + prometheus.io/port: 9100 + labels: {} + honorLabels: true + interval: 60s + selector: {} + scrapeTimeout: 10s + scheme: http + tlsConfig: {} + relabelings: [] + # - action: replace + # regex: ^(.*)$ + # replacement: $1 + # separator: ; + # sourceLabels: + # - __meta_kubernetes_pod_node_name + # targetLabel: nodename + metricRelabelings: [] + # - action: keep + # regex: kube_(daemonset|deployment|pod|namespace|node|statefulset).+ + # sourceLabels: + # - __name__ + bearerTokenFile: {} + # (use long lived access tokens) + bearerTokenSecret: {} + # name: + # key: + # optional: +livenessProbe: + enabled: true + scheme: HTTP + periodSeconds: 60 + timeoutSeconds: 10 + successThreshold: 1 + failureThreshold: 6 + initialDelaySeconds: 30 +readinessProbe: + enabled: true + scheme: HTTP + periodSeconds: 60 + timeoutSeconds: 10 + successThreshold: 1 + failureThreshold: 6 + initialDelaySeconds: 30 +ingress: + enabled: false + # className: "" + annotations: + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/server-snippets: | + location / { + proxy_set_header Upgrade $http_upgrade; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_cache_bypass $http_upgrade; + } + hosts: + - host: zigbee2mqtt.local + paths: + - path: / + pathType: ImplementationSpecific + tls: + [] + # - secretName: letsencrypt-staging + # hosts: + # - zigbee2mqtt.local + +resources: {} +# requests: +# cpu: "1" +# memory: "256Mi" +# limits: +# cpu: "1" +# memory: "512Mi" + +nodeSelector: + kubernetes.io/hostname: {} +affinity: {} +tolerations: [] + +persistence: + enabled: false + configstorage: + hostPath: /mnt/tmp + pvc: + enabled: false + # accessModes: + # - {} + # resources: + # requests: + # storage: 2Gi + # storageClassName: "" + +# Mount devices or folders from the host machine. Can be used for USB device mounting. +hostMounts: + - name: sniffer + hostPath: /dev/ttyUSB0