From b74f570b9348e91adf956f634badee7482ff4ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=97=AA=D1=94=CE=BD=CE=B9=CE=B7=20=E1=97=B7=CF=85=D0=BD?= =?UTF-8?q?=CA=9F?= Date: Thu, 17 Dec 2020 01:27:05 -0500 Subject: [PATCH] [home-assistant] migrate to common chart (#333) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [home-assistant] migrate to common chart * [home-assistant] uncomment out serviceMonitor * [home-assistant] uncomment out serviceMonitor * bump influxdb * Bump postgresql * Update charts/home-assistant/README.md Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <6213398+bjw-s@users.noreply.github.com> * Update charts/home-assistant/README.md Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <6213398+bjw-s@users.noreply.github.com> * Update charts/home-assistant/README.md Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <6213398+bjw-s@users.noreply.github.com> * fix up few review changes * Update CHANGELOG.md * Add deploykey support, vscode CI * Fix CI * bump influxdb * fix up comments * bump postgres to 10.2.0 * bump postgres to 10.2.0 * bump HA version and remove code-server * bump mariadb version * add mariadb to changelog * bump to common 2.0.0 * remove other ct-values * bump common * Delete ct-values.yaml * Update Chart.yaml * bump to 2020.12.1 * bump to 2020.12.1 * bump to 2020.12.1 Co-authored-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <6213398+bjw-s@users.noreply.github.com> --- charts/home-assistant/CHANGELOG.md | 12 + charts/home-assistant/Chart.yaml | 16 +- charts/home-assistant/OWNERS | 7 +- charts/home-assistant/README.md | 223 +++++-------- charts/home-assistant/templates/NOTES.txt | 20 +- charts/home-assistant/templates/_helpers.tpl | 53 --- charts/home-assistant/templates/common.yaml | 22 ++ .../home-assistant/templates/deployment.yaml | 295 ----------------- charts/home-assistant/templates/ingress.yaml | 39 --- charts/home-assistant/templates/pvc.yaml | 26 -- charts/home-assistant/templates/secret.yaml | 14 +- charts/home-assistant/templates/service.yaml | 65 ---- .../templates/servicemonitor.yaml | 59 ++-- .../templates/vscode-ingress.yaml | 39 --- charts/home-assistant/values.yaml | 302 +++--------------- 15 files changed, 192 insertions(+), 1000 deletions(-) delete mode 100644 charts/home-assistant/templates/_helpers.tpl create mode 100644 charts/home-assistant/templates/common.yaml delete mode 100644 charts/home-assistant/templates/deployment.yaml delete mode 100644 charts/home-assistant/templates/ingress.yaml delete mode 100644 charts/home-assistant/templates/pvc.yaml delete mode 100644 charts/home-assistant/templates/service.yaml delete mode 100644 charts/home-assistant/templates/vscode-ingress.yaml diff --git a/charts/home-assistant/CHANGELOG.md b/charts/home-assistant/CHANGELOG.md index 7cb84d51..e2c71c91 100644 --- a/charts/home-assistant/CHANGELOG.md +++ b/charts/home-assistant/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.0.0] + +### Changed + +- Migrated chart over to our common library, this version introduces breaking changes. Be sure to back up your config volume incase something goes wrong. +- Upgraded `home-assistant` container image to `2020.12.1` +- Upgraded `postgresql` subchart from version 10.1.3 to version 10.2.0. +- Upgraded `influxdb` subchart from version 1.1.2 to version 1.1.4. +- Upgraded `mariadb` subchart from version 9.1.2 to version 9.1.4 + ## [4.0.0] ### Changed @@ -48,6 +58,8 @@ Any pre-existing StatefulSet will have to be removed before upgrading due to a n This is the last version before starting this changelog. All sorts of cool stuff was changed, but only `git log` remembers what that was :slightly_frowning_face: +[5.0.0]: https://github.com/k8s-at-home/charts/tree/home-assistant-5.0.0/charts/home-assistant + [4.0.0]: https://github.com/k8s-at-home/charts/tree/home-assistant-4.0.0/charts/home-assistant [3.1.0]: https://github.com/k8s-at-home/charts/tree/home-assistant-3.1.0/charts/home-assistant diff --git a/charts/home-assistant/Chart.yaml b/charts/home-assistant/Chart.yaml index f16f5c8f..17d7dbca 100644 --- a/charts/home-assistant/Chart.yaml +++ b/charts/home-assistant/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -appVersion: 0.118.3 +appVersion: 2020.12.1 description: Home Assistant name: home-assistant -version: 4.0.0 +version: 5.0.0 keywords: - home-assistant - hass @@ -11,24 +11,24 @@ home: https://github.com/k8s-at-home/charts/tree/master/charts/home-assistant icon: https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Home_Assistant_Logo.svg/519px-Home_Assistant_Logo.svg.png sources: - https://github.com/home-assistant/home-assistant -- https://github.com/danielperna84/hass-configurator - https://github.com/cdr/code-server - https://github.com/k8s-at-home/charts/tree/master/charts/home-assistant maintainers: - name: billimek email: jeff@billimek.com -- name: runningman84 - email: phil@hellmi.de dependencies: +- name: common + repository: https://k8s-at-home.com/charts/ + version: 2.0.4 - name: postgresql - version: 10.1.3 + version: 10.2.0 repository: https://charts.bitnami.com/bitnami condition: postgresql.enabled - name: mariadb - version: 9.1.2 + version: 9.1.4 repository: https://charts.bitnami.com/bitnami condition: mariadb.enabled - name: influxdb - version: 1.1.2 + version: 1.1.4 repository: https://charts.bitnami.com/bitnami condition: influxdb.enabled diff --git a/charts/home-assistant/OWNERS b/charts/home-assistant/OWNERS index b7fc7f20..1ce35762 100644 --- a/charts/home-assistant/OWNERS +++ b/charts/home-assistant/OWNERS @@ -1,7 +1,8 @@ approvers: - billimek -- runningman84 +- onedr0p +- bjw-s reviewers: - billimek -- runningman84 - +- onedr0p +- bjw-s diff --git a/charts/home-assistant/README.md b/charts/home-assistant/README.md index 12528f54..c916c15b 100644 --- a/charts/home-assistant/README.md +++ b/charts/home-assistant/README.md @@ -1,189 +1,114 @@ # Home Assistant -This is a helm chart for [Home Assistant](https://www.home-assistant.io/) +This is a helm chart for [Home Assistant](https://www.home-assistant.io/). **This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)** ## TL;DR; ```shell -helm repo add k8s-at-home https://k8s-at-home.com/charts/ -helm install k8s-at-home/home-assistant +$ helm repo add k8s-at-home https://k8s-at-home.com/charts/ +$ helm install k8s-at-home/home-assistant ``` ## :star2: Changelog Please refer to [CHANGELOG.md](CHANGELOG.md) for an overview of notable changes to the chart. **This is especially important for major version updates!** -## Introduction - -This code is adapted for [the official home assistant docker image](https://hub.docker.com/r/homeassistant/home-assistant/) - ## Installing the Chart To install the chart with the release name `my-release`: -```shell +```console helm install --name my-release k8s-at-home/home-assistant ``` +### Z-Wave / Zigbee + +A Z-Wave and/or Zigbee controller device could be used with Home Assistant if passed through from the host to the pod. Skip this section if you are using zwave2mqtt and/or zigbee2mqtt or plan to. + +First you will need to mount your Z-Wave and/or Zigbee device into the pod, you can do so by adding the following to your values: + +```yaml +additionalVolumeMounts: + - name: zwave-usb + mountPath: /path/to/device + +additionalVolumes: + - name: zwave-usb + hostPath: + path: /path/to/device +``` + +Second you will need to set a nodeAffinity rule, for example: + +```yaml +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: app + operator: In + values: + - zwave-controller +``` + +... where a node with an attached zwave and/or zigbee controller USB device is labeled with `app: zwave-controller` + ## Uninstalling the Chart To uninstall/delete the `my-release` deployment: -```shell +```console helm delete my-release --purge ``` The command removes all the Kubernetes components associated with the chart and deletes the release. -## Configuration - -The following tables lists the configurable parameters of the Home Assistant chart and their default values. - -| Parameter | Description | Default | -|-------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| -| `image.repository` | Image repository | `homeassistant/home-assistant` | -| `image.tag` | Image tag. Possible values listed [here](https://hub.docker.com/r/homeassistant/home-assistant/tags/). | `0.118.3` | -| `image.pullPolicy` | Image pull policy | `IfNotPresent` | -| `image.pullSecrets` | Secrets to use when pulling the image | `[]` | -| `strategyType` | Specifies the strategy used to replace old Pods by new ones | `Recreate` | -| `probes.liveness.enabled` | Use the livenessProbe? | `true` | -| `probes.liveness.scheme` | Specify liveness `scheme` parameter for the deployment | `HTTP` | -| `probes.liveness.initialDelaySeconds` | Specify liveness `initialDelaySeconds` parameter for the deployment | `60` | -| `probes.liveness.failureThreshold` | Specify liveness `failureThreshold` parameter for the deployment | `5` | -| `probes.liveness.timeoutSeconds` | Specify liveness `timeoutSeconds` parameter for the deployment | `10` | -| `probes.readiness.enabled` | Use the readinessProbe? | `true` | -| `probes.readiness.scheme` | Specify readiness `scheme` parameter for the deployment | `HTTP` | -| `probes.readiness.initialDelaySeconds` | Specify readiness `initialDelaySeconds` parameter for the deployment | `60` | -| `probes.readiness.failureThreshold` | Specify readiness `failureThreshold` parameter for the deployment | `5` | -| `probes.readiness.timeoutSeconds` | Specify readiness `timeoutSeconds` parameter for the deployment | `10` | -| `probes.startup.enabled` | Use the startupProbe? (new in kubernetes 1.16) | `false` | -| `probes.startup.scheme` | Specify startup `scheme` parameter for the deployment | `HTTP` | -| `probes.startup.failureThreshold` | Specify startup `failureThreshold` parameter for the deployment | `5` | -| `probes.startup.periodSeconds` | Specify startup `periodSeconds` parameter for the deployment | `10` | -| `service.type` | Kubernetes service type for the home-assistant GUI | `ClusterIP` | -| `service.port` | Kubernetes port where the home-assistant GUI is exposed | `8123` | -| `service.portName` | Kubernetes port name where the home-assistant GUI is exposed | `api` | -| `service.additionalPorts` | Add additional ports exposed by the home assistant container integrations. Example homematic needs to expose a proxy port | `{}` | -| `service.annotations` | Service annotations for the home-assistant GUI | `{}` | -| `service.clusterIP` | Cluster IP for the home-assistant GUI | `` | -| `service.externalIPs` | External IPs for the home-assistant GUI | `[]` | -| `service.loadBalancerIP` | Loadbalancer IP for the home-assistant GUI | `` | -| `service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the home-assistant GUI | `[]` | -| `service.publishNotReadyAddresses` | Set to true if the editors (vscode or configurator) should be reachable when home assistant does not run | `false` | -| `service.externalTrafficPolicy` | Loadbalancer externalTrafficPolicy | `` | -| `hostNetwork` | Enable hostNetwork - might be needed for discovery to work | `false` | -| `hostAliases` | Define custom entries in /etc/hosts | `[]` | -| `service.nodePort` | nodePort to listen on for the home-assistant GUI | `` | -| `ingress.enabled` | Enables Ingress | `false` | -| `ingress.annotations` | Ingress annotations | `{}` | -| `ingress.path` | Ingress path | `/` | -| `ingress.hosts` | Ingress accepted hostnames | `chart-example.local` | -| `ingress.tls` | Ingress TLS configuration | `[]` | -| `persistence.enabled` | Use persistent volume to store data | `true` | -| `persistence.size` | Size of persistent volume claim | `5Gi` | -| `persistence.existingClaim` | Use an existing PVC to persist data | `nil` | -| `persistence.hostPath` | The path to the config directory on the host, instead of a PVC | `nil` | -| `persistence.storageClass` | Type of persistent volume claim | `-` | -| `persistence.accessMode` | Persistence access modes | `ReadWriteMany` | -| `persistence.configSubPath` | An optional subPath for the config volumeMount | `` | -| `git.enabled` | Use git-sync in init container | `false` | -| `git.secret` | Git secret to use for git-sync | `git-creds` | -| `git.syncPath` | Git sync path | `/config` | -| `git.keyPath` | Git ssh key path | `/root/.ssh` | -| `git.user.name` | Human-readable name in the “committer” and “author” fields | `` | -| `git.user.email` | Email address for the “committer” and “author” fields | `` | -| `zwave.enabled` | Enable zwave host device passthrough. Also enables privileged container mode. | `false` | -| `zwave.device` | Device to passthrough to guest | `ttyACM0` | -| `hostMounts` | Array of host directories to mount; can be used for devices | [] | -| `hostMounts.name` | Name of the volume | `nil` | -| `hostMounts.hostPath` | The path on the host machine | `nil` | -| `hostMounts.mountPath` | The path at which to mount (optional; assumed same as hostPath) | `nil` | -| `hostMounts.type` | The type to mount (optional, i.e., `Directory`) | `nil` | -| `extraEnv` | Extra ENV vars to pass to the home-assistant container | `{}` | -| `extraEnvSecrets` | Extra env vars to pass to the home-assistant container from k8s secrets - see `values.yaml` for an example | `{}` | -| `vscode.enabled` | Enable the optional [VS Code Server Sidecar](https://github.com/cdr/code-server) | `false` | -| `vscode.image.repository` | Image repository | `codercom/code-server` | -| `vscode.image.tag` | Image tag | `3.7.2` | -| `vscode.image.pullPolicy` | Image pull policy | `IfNotPresent` | -| `vscode.hassConfig` | Base path of the home assistant configuration files | `/config` | -| `vscode.vscodePath` | Base path of the VS Code configuration files | `/config/.vscode` | -| `vscode.password` | If this is set, will require a password to access the VS Code Server UI | `` | -| `vscode.extraEnv` | Extra ENV vars to pass to the configuration UI | `{}` | -| `vscode.args` | Optional arguments to pass into vscode image. Defaulting to "-" uses default arguments. | `-` | -| `vscode.ingress.enabled` | Enables Ingress for the VS Code UI | `false` | -| `vscode.ingress.annotations` | Ingress annotations for the VS Code UI | `{}` | -| `vscode.ingress.hosts` | Ingress accepted hostnames for the VS Code UI | `chart-example.local` | -| `vscode.ingress.tls` | Ingress TLS configuration for the VS Code UI | `[]` | -| `vscode.resources` | CPU/Memory resource requests/limits for the VS Code UI | `{}` | -| `vscode.securityContext` | Security context to be added to hass-vscode pods for the VS Code UI | `{}` | -| `vscode.service.type` | Kubernetes service type for the VS Code UI | `ClusterIP` | -| `vscode.service.port` | Kubernetes port where the vscode UI is exposed | `80` | -| `vscode.service.nodePort` | nodePort to listen on for the VS Code UI | `` | -| `vscode.service.annotations` | Service annotations for the VS Code UI | `{}` | -| `vscode.service.labels` | Service labels to use for the VS Code UI | `{}` | -| `vscode.service.clusterIP` | Cluster IP for the VS Code UI | `` | -| `vscode.service.externalIPs` | External IPs for the VS Code UI | `[]` | -| `vscode.service.loadBalancerIP` | Loadbalancer IP for the VS Code UI | `` | -| `vscode.service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the VS Code UI | `[]` | -| `mariadb.enabled` | Enable the optional [Mariadb](https://github.com/bitnami/charts) deployment | `false` | -| `postgresql.enabled` | Enable the optional [Postgres](https://github.com/bitnami/charts) deployment | `false` | -| `influxdb.enabled` | Enable the optional [Influxdb](https://github.com/bitnami/charts) deployment | `false` | -| `resources` | CPU/Memory resource requests/limits or the home-assistant GUI | `{}` | -| `nodeSelector` | Node labels for pod assignment or the home-assistant GUI | `{}` | -| `tolerations` | Toleration labels for pod assignment or the home-assistant GUI | `[]` | -| `affinity` | Affinity settings for pod assignment or the home-assistant GUI | `{}` | -| `podAnnotations` | Key-value pairs to add as pod annotations | `{}` | -| `extraVolumes` | Any extra volumes to define for the pod | `{}` | -| `extraVolumeMounts` | Any extra volumes mounts to define for each container of the pod | `{}` | -| `monitoring.enabled` | Enables Monitoring support | `false` | -| `monitoring.serviceMonitor.enabled` | Setup a ServiceMonitor to configure scraping | `false` | -| `monitoring.serviceMonitor.namespace` | Set the namespace the ServiceMonitor should be deployed | `false` | -| `monitoring.serviceMonitor.interval` | Set how frequently Prometheus should scrape | `30` | -| `monitoring.serviceMonitor.labels` | Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator | `{}` | -| `monitoring.serviceMonitor.bearerTokenFile` | Set bearerTokenFile for home-assistant auth (use long lived access tokens) | `nil` | -| `monitoring.serviceMonitor.bearerTokenSecret` | Set bearerTokenSecret for home-assistant auth (use long lived access tokens) | `nil` | -| `monitoring.serviceMonitor.metricRelabelings` | Add metricRelabelings [Documentation](https://coreos.com/operators/prometheus/docs/latest/api.html#relabelconfig) | `{}` | +Read through the charts [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/home-assistant/values.yaml) +file. It has several commented out suggested values. +Additionally you can take a look at the common library [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/common/values.yaml) for more (advanced) configuration options. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, - -```shell -helm install --name my-release \ - --set configurator.hassApiPassword="$HASS_API_PASSWORD" \ +```console +helm install my-release \ + --set env.TZ="America/New_York" \ k8s-at-home/home-assistant ``` - -Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, - -```shell -helm install --name my-release -f values.yaml k8s-at-home/home-assistant +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the +chart. For example, +```console +helm install my-release k8s-at-home/home-assistant --values values.yaml ``` -Read through the [values.yaml](values.yaml) file. It has several commented out suggested values. - -## Configuring home assistant - -Much of the home assistant configuration occurs inside the various files persisted to the `/config` directory. This will require external access to the persistent storage location where the home assistant configuration data is stored. Because this may be a limitation, there are two options built-in to this chart: - -### VS Code Server - -[VS Code Server](https://github.com/cdr/code-server) is added as an optional sidecar container to Home Assistant with access to the home assistant configuration for easy in-browser editing and manipulation of Home Assistant. If using this, it is possible to manually install the [Home Assistant Config Helper Extension](https://github.com/keesschollaart81/vscode-home-assistant) in order to have a deeper integration with Home Assistant within VS Code while editing the configuration files. - -## Git sync secret - -In order to sync the home assistant from a git repo, you can optionally store an ssh key as a kubernetes git secret: -```shell -kubectl create secret generic git-creds --from-file=id_rsa=git/k8s_id_rsa --from-file=known_hosts=git/known_hosts --from-file=id_rsa.pub=git/k8s_id_rsa.pub +```yaml +image: + tag: ... ``` -## git-crypt support +--- +**NOTE** -When using Git sync it is possible to specify a file called `git-crypt-key` in the secret referred to in `git.secret`. When this file is present, `git-crypt unlock` will automatically be executed after the repo has been synced. - -**Note:** `git-crypt` is not installed by default in the other images! If you wish to push changes from the VS Code or Configurator containers, you will have to make sure that it is installed. - -The value for this secret can be obtained by running the following command in an unlocked version of your Home Assistant settings repo. It will export the unlock key, base64 encode it and copy it to your clipboard. -```shell -git-crypt export-key ./tmp-key && cat ./tmp-key | base64 | pbcopy && rm ./tmp-key +If you get +```console +Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: ...` ``` +it may be because you uninstalled the chart with `skipuninstall` enabled, you need to manually delete the pvc or use `existingClaim`. + +--- + +## Upgrading an existing Release to a new major version + +A major chart version change (like 4.0.1 -> 5.0.0) indicates that there is an incompatible breaking change potentially needing manual actions. + +### Upgrading from 4.x.x to 5.x.x + +As of 5.0.0 this chart was migrated to a centralized [common](https://github.com/k8s-at-home/charts/tree/master/charts/common) library, some values in `values.yaml` have changed. + +Examples: + +* `service.port` has been moved to `service.port.port`. +* `persistence.type` has been moved to `controllerType`. + +Refer to the [common](https://github.com/k8s-at-home/charts/tree/master/charts/common) library for more configuration options. diff --git a/charts/home-assistant/templates/NOTES.txt b/charts/home-assistant/templates/NOTES.txt index 8bc0903c..90f7b653 100644 --- a/charts/home-assistant/templates/NOTES.txt +++ b/charts/home-assistant/templates/NOTES.txt @@ -1,19 +1 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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 svc -w {{ template "home-assistant.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "home-assistant.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - 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={{ template "home-assistant.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +{{- include "common.notes.defaultNotes" . -}} diff --git a/charts/home-assistant/templates/_helpers.tpl b/charts/home-assistant/templates/_helpers.tpl deleted file mode 100644 index 4f65f054..00000000 --- a/charts/home-assistant/templates/_helpers.tpl +++ /dev/null @@ -1,53 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -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 -}} - -{{/* -Create argument list for vscode image. -*/}} -{{- define "home-assistant.vscode.args" -}} -{{- if empty .Values.vscode.args -}} -{{- "" -}} -{{- else if (eq (typeOf .Values.vscode.args) "string") -}} -- --port={{ .Values.vscode.service.port }} -{{- if not (.Values.vscode.password) }} -- --auth=none -{{- end }} -{{- if .Values.vscode.vscodePath }} -- --extensions-dir={{ .Values.vscode.vscodePath }} -- --user-data-dir={{ .Values.vscode.vscodePath }} -- {{ .Values.vscode.hassConfig }} -{{- end }} -{{- else -}} -{{ toYaml .Values.vscode.args }} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/charts/home-assistant/templates/common.yaml b/charts/home-assistant/templates/common.yaml new file mode 100644 index 00000000..07f6eca9 --- /dev/null +++ b/charts/home-assistant/templates/common.yaml @@ -0,0 +1,22 @@ +{{/* Make sure all variables are set properly */}} +{{- include "common.values.setup" . }} + +{{/* Append the ssh secret to the additionalVolumes */}} +{{- define "home-assistant.gitSecret.volume" -}} +name: deploykey +secret: + secretName: {{ template "common.names.fullname" . }}-deploykey + defaultMode: 256 + optional: true +{{- end -}} + +{{- if .Values.git.deployKey -}} + {{- $volume := include "home-assistant.gitSecret.volume" . | fromYaml -}} + {{- if $volume -}} + {{- $additionalVolumes := append .Values.additionalVolumes $volume }} + {{- $_ := set .Values "additionalVolumes" (deepCopy $additionalVolumes) -}} + {{- end -}} +{{- end -}} + +{{/* Render the templates */}} +{{ include "common.all" . }} diff --git a/charts/home-assistant/templates/deployment.yaml b/charts/home-assistant/templates/deployment.yaml deleted file mode 100644 index cee1d7a6..00000000 --- a/charts/home-assistant/templates/deployment.yaml +++ /dev/null @@ -1,295 +0,0 @@ -{{- $args := include "home-assistant.vscode.args" . -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "home-assistant.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - replicas: 1 - strategy: - type: {{ .Values.strategyType }} - selector: - matchLabels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - {{- if .Values.podAnnotations }} - annotations: - {{- range $key, $value := .Values.podAnnotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- end }} - spec: - {{- with .Values.image.pullSecrets }} - imagePullSecrets: - {{- range . }} - - name: {{ . }} - {{- end }} - {{- end }} - {{- if .Values.hostNetwork }} - hostNetwork: {{ .Values.hostNetwork }} - dnsPolicy: ClusterFirstWithHostNet - {{- end }} - {{- if .Values.hostAliases }} - hostAliases: -{{ toYaml .Values.hostAliases | indent 8 }} - {{- end }} - initContainers: - {{- if .Values.git.enabled }} - - name: git-sync - image: "{{ .Values.git.image.repository }}:{{ .Values.git.image.tag }}" - imagePullPolicy: {{ .Values.git.image.pullPolicy }} - {{- if .Values.git.command }} - command: - {{- range .Values.git.command }} - - {{ . | quote }} - {{- end }} - {{- else }} - command: ["/bin/sh", "-c"] - args: - - set -e; - if [ -d "{{ .Values.git.syncPath }}/.git" ]; - then - git -C "{{ .Values.git.syncPath }}" pull || true; - else - if [ "$(ls -A {{ .Values.git.syncPath }})" ]; - then - git clone --depth 2 "{{ .Values.git.repo }}" /tmp/repo; - cp -rf /tmp/repo/.git "{{ .Values.git.syncPath }}"; - cd "{{ .Values.git.syncPath }}"; - git checkout -f; - else - git clone --depth 2 "{{ .Values.git.repo }}" "{{ .Values.git.syncPath }}"; - fi; - fi; - if [ -f "{{ .Values.git.keyPath }}/git-crypt-key" ]; - then - cd {{ .Values.git.syncPath }}; - git-crypt unlock "{{ .Values.git.keyPath }}/git-crypt-key"; - fi; - {{- end }} - volumeMounts: - - mountPath: /config - name: config - subPath: {{ default "" .Values.persistence.configSubPath }} - - mountPath: {{ .Values.git.keyPath }} - name: git-secret - {{- if .Values.extraVolumeMounts }}{{ toYaml .Values.extraVolumeMounts | trim | nindent 8 }}{{ end }} - {{- if .Values.usePodSecurityContext }} - securityContext: - runAsUser: {{ default 0 .Values.runAsUser }} - {{- if and (.Values.runAsUser) (.Values.fsGroup) }} - {{- if not (eq .Values.runAsUser 0.0) }} - fsGroup: {{ .Values.fsGroup }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: api - containerPort: {{ .Values.service.port }} - protocol: TCP - {{- range .Values.service.additionalPorts }} - - name: {{ .name }} - containerPort: {{ .targetPort }} - {{- end }} - {{- if .Values.probes.liveness.enabled }} - livenessProbe: - httpGet: - path: / - port: api - scheme: {{ .Values.probes.liveness.scheme }} - initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} - failureThreshold: {{ .Values.probes.liveness.failureThreshold }} - timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }} - {{- end }} - {{- if .Values.probes.readiness.enabled }} - readinessProbe: - httpGet: - path: / - port: api - scheme: {{ .Values.probes.readiness.scheme }} - initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} - failureThreshold: {{ .Values.probes.readiness.failureThreshold }} - timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} - {{- end }} - {{- if .Values.probes.startup.enabled }} - startupProbe: - httpGet: - path: / - port: api - scheme: {{ .Values.probes.startup.scheme }} - failureThreshold: {{ .Values.probes.startup.failureThreshold }} - periodSeconds: {{ .Values.probes.startup.periodSeconds }} - {{- end }} - env: - {{- range $key, $value := .Values.extraEnv }} - - name: {{ $key }} - value: {{ $value | quote }} - {{- end }} - {{- range $name, $opts := .Values.extraEnvSecrets }} - - name: {{ $name }} - valueFrom: - secretKeyRef: - name: {{ $opts.secret }} - key: {{ $opts.key }} - {{- end }} - envFrom: - {{- range .Values.extraSecretForEnvFrom }} - - secretRef: - name: {{ . }} - {{- end }} - volumeMounts: - - mountPath: /config - name: config - subPath: {{ default "" .Values.persistence.configSubPath }} - {{- if .Values.zwave.enabled }} - - mountPath: /dev/ttyACM0 - name: ttyacm - {{- end }} - {{- range .Values.hostMounts }} - {{- if .mountPath }} - - mountPath: {{ .mountPath }} - {{- else }} - - mountPath: {{ .hostPath }} - {{- end }} - name: {{ .name }} - {{- end }} - {{- if .Values.git.enabled }} - - mountPath: {{ .Values.git.keyPath }} - name: git-secret - {{- end }} - {{- if .Values.extraVolumeMounts }}{{ toYaml .Values.extraVolumeMounts | trim | nindent 10 }}{{ end }} - {{- if .Values.usePodSecurityContext }} - securityContext: - runAsUser: {{ default 0 .Values.runAsUser }} - {{- if and (.Values.runAsUser) (.Values.fsGroup) }} - {{- if not (eq .Values.runAsUser 0.0) }} - fsGroup: {{ .Values.fsGroup }} - {{- end }} - {{- end }} - {{- end }} - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- if or .Values.zwave.enabled (.Values.hostMounts) }} - securityContext: - privileged: true - allowPrivilegeEscalation: true - {{- end }} - {{- if .Values.vscode.enabled }} - - name: vscode - image: "{{ .Values.vscode.image.repository }}:{{ .Values.vscode.image.tag }}" - imagePullPolicy: {{ .Values.vscode.image.pullPolicy }} - workingDir: {{ .Values.vscode.hassConfig }} - args: -{{- with $args }} -{{ . | indent 12 }} -{{- end }} - ports: - - name: vscode - containerPort: {{ .Values.vscode.service.port }} - protocol: TCP - env: - {{- if .Values.vscode.password }} - - name: PASSWORD - valueFrom: - secretKeyRef: - name: {{ template "home-assistant.fullname" . }}-vscode - key: password - {{- end }} - {{- if and (.Values.git.enabled) (.Values.git.user.name) }} - - name: GIT_AUTHOR_NAME - value: {{ .Values.git.user.name }} - - name: GIT_COMMITTER_NAME - value: {{ .Values.git.user.name }} - {{ end }} - {{- if and (.Values.git.enabled) (.Values.git.user.email) }} - - name: GIT_AUTHOR_EMAIL - value: {{ .Values.git.user.email }} - - name: GIT_COMMITTER_EMAIL - value: {{ .Values.git.user.email }} - {{ end }} - {{- range $key, $value := .Values.vscode.extraEnv }} - - name: {{ $key }} - value: {{ $value | quote }} - {{- end }} - volumeMounts: - - mountPath: /config - name: config - subPath: {{ default "" .Values.persistence.configSubPath }} - {{- if .Values.git.enabled }} - - mountPath: {{ .Values.git.keyPath }} - name: git-secret - {{- end }} - {{- if .Values.extraVolumeMounts }}{{ toYaml .Values.extraVolumeMounts | trim | nindent 10 }}{{ end }} - {{- if .Values.usePodSecurityContext }} - securityContext: - runAsUser: {{ default 0 .Values.runAsUser }} - {{- if and (.Values.runAsUser) (.Values.fsGroup) }} - {{- if not (eq .Values.runAsUser 0.0) }} - fsGroup: {{ .Values.fsGroup }} - {{- end }} - {{- end }} - {{- end }} - resources: -{{ toYaml .Values.vscode.resources | indent 12 }} - {{- end }} - volumes: - - name: config - {{- if .Values.persistence.enabled }} - {{- if .Values.persistence.hostPath }} - hostPath: - path: {{.Values.persistence.hostPath}} - type: Directory - {{- else }} - persistentVolumeClaim: - claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "home-assistant.fullname" . }}{{- end }} - {{- end }} - {{- else }} - emptyDir: {} - {{ end }} - {{- if .Values.zwave.enabled }} - - name: ttyacm - hostPath: - path: /dev/{{.Values.zwave.device}} - {{- end }} - {{- range .Values.hostMounts }} - - name: {{ .name }} - hostPath: - path: {{.hostPath}} - {{- if .type }} - type: {{ .type }} - {{- end }} - {{- end }} - {{- if .Values.git.enabled }} - - name: git-secret - secret: - defaultMode: 256 - secretName: {{ .Values.git.secret }} - optional: true - {{ end }} - {{- if .Values.extraVolumes }}{{ toYaml .Values.extraVolumes | trim | nindent 6 }}{{ end }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} diff --git a/charts/home-assistant/templates/ingress.yaml b/charts/home-assistant/templates/ingress.yaml deleted file mode 100644 index 71eb3508..00000000 --- a/charts/home-assistant/templates/ingress.yaml +++ /dev/null @@ -1,39 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "home-assistant.fullname" . -}} -{{- $servicePort := .Values.service.port -}} -{{- $ingressPath := .Values.ingress.path -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: {{ $servicePort }} - {{- end }} -{{- end }} diff --git a/charts/home-assistant/templates/pvc.yaml b/charts/home-assistant/templates/pvc.yaml deleted file mode 100644 index 13616b7c..00000000 --- a/charts/home-assistant/templates/pvc.yaml +++ /dev/null @@ -1,26 +0,0 @@ -{{- if .Values.persistence.enabled -}} -{{- if not .Values.persistence.existingClaim -}} -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: {{ template "home-assistant.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - accessModes: - - {{ .Values.persistence.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} -{{- if .Values.persistence.storageClass }} -{{- if (eq "-" .Values.persistence.storageClass) }} - storageClassName: "" -{{- else }} - storageClassName: "{{ .Values.persistence.storageClass }}" -{{- end }} -{{- end }} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/charts/home-assistant/templates/secret.yaml b/charts/home-assistant/templates/secret.yaml index b842873d..2582f876 100644 --- a/charts/home-assistant/templates/secret.yaml +++ b/charts/home-assistant/templates/secret.yaml @@ -1,17 +1,11 @@ -{{- if .Values.vscode.enabled }} ---- +{{- if .Values.git.deployKey }} apiVersion: v1 kind: Secret metadata: - name: {{ template "home-assistant.fullname" . }}-vscode + name: {{ template "common.names.fullname" . }}-deploykey labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "common.labels" . | nindent 4 }} type: Opaque data: - {{- if .Values.vscode.password }} - password: {{ .Values.vscode.password | b64enc | quote }} - {{- end }} + id_rsa: {{ .Values.git.deployKey | b64enc | quote }} {{- end }} diff --git a/charts/home-assistant/templates/service.yaml b/charts/home-assistant/templates/service.yaml deleted file mode 100644 index c37d1f9f..00000000 --- a/charts/home-assistant/templates/service.yaml +++ /dev/null @@ -1,65 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "home-assistant.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- if .Values.service.labels }} -{{ toYaml .Values.service.labels | indent 4 }} -{{- end }} -{{- with .Values.service.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }} - type: ClusterIP - {{- if .Values.service.clusterIP }} - clusterIP: {{ .Values.service.clusterIP }} - {{end}} -{{- else if eq .Values.service.type "LoadBalancer" }} - type: {{ .Values.service.type }} - {{- if .Values.service.loadBalancerIP }} - loadBalancerIP: {{ .Values.service.loadBalancerIP }} - {{- end }} - {{- if .Values.service.externalTrafficPolicy }} - externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} - {{- end }} - {{- if .Values.service.loadBalancerSourceRanges }} - loadBalancerSourceRanges: -{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} - {{- end -}} -{{- else }} - type: {{ .Values.service.type }} -{{- end }} -{{- if .Values.service.externalIPs }} - externalIPs: -{{ toYaml .Values.service.externalIPs | indent 4 }} -{{- end }} - publishNotReadyAddresses: {{ .Values.service.publishNotReadyAddresses }} - ports: - - name: {{ .Values.service.portName }} - port: {{ .Values.service.port }} - protocol: TCP - targetPort: 8123 -{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} - nodePort: {{.Values.service.nodePort}} -{{ end }} -{{- if .Values.vscode.enabled }} - - name: vscode - port: {{ .Values.vscode.service.port }} - protocol: TCP - targetPort: {{ .Values.vscode.service.port }} -{{ if (and (eq .Values.vscode.service.type "NodePort") (not (empty .Values.vscode.service.nodePort))) }} - nodePort: {{.Values.vscode.service.nodePort}} -{{ end }} -{{- end }} -{{- if .Values.service.additionalPorts }} - {{- .Values.service.additionalPorts | toYaml | indent 4 }} -{{- end }} - selector: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/home-assistant/templates/servicemonitor.yaml b/charts/home-assistant/templates/servicemonitor.yaml index ed1f5d7b..c2369217 100644 --- a/charts/home-assistant/templates/servicemonitor.yaml +++ b/charts/home-assistant/templates/servicemonitor.yaml @@ -1,43 +1,32 @@ -{{- if and ( .Values.monitoring.serviceMonitor.enabled ) ( .Values.monitoring.enabled ) }} +{{- if .Values.prometheus.serviceMonitor.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: -{{- if .Values.monitoring.serviceMonitor.labels }} + name: {{ template "common.names.fullname" . }} labels: -{{ toYaml .Values.monitoring.serviceMonitor.labels | indent 4}} -{{- end }} - name: {{ template "home-assistant.fullname" . }}-prometheus-exporter -{{- if .Values.monitoring.serviceMonitor.namespace }} - namespace: {{ .Values.monitoring.serviceMonitor.namespace }} -{{- end }} + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.prometheus.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: - endpoints: - - targetPort: {{ .Values.service.portName }} - path: /api/prometheus -{{- if .Values.monitoring.serviceMonitor.interval }} - interval: {{ .Values.monitoring.serviceMonitor.interval }} -{{- 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 }} -{{- if .Values.monitoring.serviceMonitor.metricRelabelings }} - metricRelabelings: -{{ toYaml .Values.monitoring.serviceMonitor.metricRelabelings | indent 4 }} -{{- end }} - jobLabel: {{ template "home-assistant.fullname" . }}-prometheus-exporter - namespaceSelector: - matchNames: - - {{ .Release.Namespace }} selector: matchLabels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "common.labels.selectorLabels" . | nindent 6 }} + endpoints: + - port: {{ default "http" .Values.service.port.name }} + {{- with .Values.prometheus.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.prometheus.serviceMonitor.bearerTokenFile }} + bearerTokenFile: {{ . }} + {{- end }} + {{- with .Values.prometheus.serviceMonitor.bearerTokenSecret }} + bearerTokenSecret: + name: {{ .name }} + key: {{ .key }} + {{- with .optional }} + optional: {{ . }} + {{- end }} + {{- end }} + path: /api/prometheus {{- end }} diff --git a/charts/home-assistant/templates/vscode-ingress.yaml b/charts/home-assistant/templates/vscode-ingress.yaml deleted file mode 100644 index d3e17efd..00000000 --- a/charts/home-assistant/templates/vscode-ingress.yaml +++ /dev/null @@ -1,39 +0,0 @@ -{{- if and (.Values.vscode.enabled) (.Values.vscode.ingress.enabled) }} -{{- $fullName := include "home-assistant.fullname" . -}} -{{- $servicePort := .Values.vscode.service.port -}} -{{- $ingressPath := .Values.vscode.ingress.path -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }}-vscode - labels: - app.kubernetes.io/name: {{ include "home-assistant.name" . }} - helm.sh/chart: {{ include "home-assistant.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.vscode.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.vscode.ingress.tls }} - tls: - {{- range .Values.vscode.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.vscode.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: {{ $servicePort }} - {{- end }} -{{- end }} diff --git a/charts/home-assistant/values.yaml b/charts/home-assistant/values.yaml index 395f7027..e24242de 100644 --- a/charts/home-assistant/values.yaml +++ b/charts/home-assistant/values.yaml @@ -1,280 +1,64 @@ -# Default values for home-assistant. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. +# Default values for zwave2mqtt. image: repository: homeassistant/home-assistant - tag: 0.118.3 pullPolicy: IfNotPresent - pullSecrets: [] + tag: 2020.12.1 -# upgrade strategy type (e.g. Recreate or RollingUpdate) -strategyType: Recreate +strategy: + type: Recreate -# Probes configuration -probes: - liveness: - enabled: true - scheme: HTTP - initialDelaySeconds: 60 - failureThreshold: 5 - timeoutSeconds: 10 - readiness: - enabled: true - scheme: HTTP - initialDelaySeconds: 60 - failureThreshold: 5 - timeoutSeconds: 10 - startup: - enabled: false - scheme: HTTP - failureThreshold: 30 - periodSeconds: 10 +env: {} + # TZ: service: - type: ClusterIP - port: 8123 - portName: api - additionalPorts: [] - # - name: homematicproxy - # port: 2001 - # targetPort: 2001 - annotations: {} - labels: {} - clusterIP: "" - ## List of IP addresses at which the hass-configurator service is available - ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips - ## - externalIPs: [] - loadBalancerIP: "" - loadBalancerSourceRanges: [] - # nodePort: 30000 - publishNotReadyAddresses: false + port: + port: 8123 -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - home-assistant.local - tls: [] - # - secretName: home-assistant-tls - # hosts: - # - home-assistant.local +# # Enable devices to be discoverable +# hostNetwork: true -hostNetwork: false - -hostAliases: [] - # Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. - # ref: https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/ - # - ip: "192.168.1.100" - # hostnames: - # - "example.com" - # - "www.example.com" - -persistence: - enabled: true - ## home-assistant data Persistent Volume Storage Class - ## If defined, storageClassName: - ## 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: "-" - ## - ## If you want to reuse an existing claim, you can pass the name of the PVC using - ## the existingClaim variable - # existingClaim: your-claim - ## - ## If you want to use a volume on the host machine instead of a PVC: - # hostPath: /path/to/the/config/folder - accessMode: ReadWriteOnce - size: 5Gi - # If you use an existingClaim is sometimes useful to specify a subPath within the volume to mount instead of mounting the root. - # This allows several charts to share a common volume. For example for configurations. - # configSubPath: configs/hass - -## Additional hass container environment variable -## For instance to add a http_proxy -## -extraEnv: {} - -## Additional hass container environment variable from k8s secrets -## For instance to add a password -## can use `!env_var` in the home assistant configuration to reference these variables -extraEnvSecrets: - # Example - # 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: [] -# - home-assistant-secrets - -# Enable pod security context (must be `true` if runAsUser or fsGroup are set) -usePodSecurityContext: true -# Set runAsUser to 1000 to let home-assistant run as non-root user 'hass' which exists in 'runningman84/alpine-homeassistant' docker image. -# When setting runAsUser to a different value than 0 also set fsGroup to the same value: -# runAsUser: -# fsGroup: +# # Enable passing thru a USB device to Home Assistant +# securityContext: +# privileged: true git: - enabled: false + deployKey: "" - image: - repository: k8sathome/git-crypt - tag: 2020.09.28 - pullPolicy: IfNotPresent - - ## Specify the command that runs in the git-sync container to pull in configuration. - # command: [] - - # Committer settings - user: - name: "" - email: "" - - repo: "" - secret: git-creds - syncPath: /config - keyPath: /root/.ssh - -zwave: - enabled: false - device: ttyACM0 - -# Mount devices or folders from the host machine. Can be used for USB device mounting. -hostMounts: [] - # Example - # - name: zha - # hostPath: /dev/serial/by-id/usb-Silicon_Labs_HubZ_Smart_Home_Controller_6120245D-if01-port0 - -## Add support for Prometheus -# settings has to be enabled in configuration.yaml -# https://www.home-assistant.io/components/prometheus/ -monitoring: - enabled: false +# Enable a prometheus-operator servicemonitor +prometheus: serviceMonitor: - # When set true and if Prometheus Operator is installed then use a ServiceMonitor to configure scraping - enabled: true - # Set the namespace the ServiceMonitor should be deployed - # namespace: monitoring - # Set how frequently Prometheus should scrape - # interval: 30s - # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator - # labels: - # Set bearerTokenFile for home assistant auth (use long lived access tokens) - # bearerTokenFile: - # Set bearerTokenSecret for home assistant auth (use long lived access tokens) - # bearerTokenSecret: - # Relabel metrics if needed example removes pod and instance labels from metrics beginning with hass - # metricRelabelings: [] - # - regex: hass.* - # replacement: "" - # sourceLabels: - # - __name__ - # targetLabel: pod - # - regex: hass_.* - # replacement: "" - # sourceLabels: - # - __name__ - # targetLabel: instance - -vscode: - enabled: false - - ## code-server container image - ## - image: - repository: codercom/code-server - tag: 3.7.2 - pullPolicy: IfNotPresent - - ## VSCode password - # password: - - ## path where the home assistant configuration is stored - hassConfig: /config - - ## path where the VS Code data should reside - vscodePath: /config/.vscode - - ## Additional hass-vscode container environment variable - ## For instance to add a http_proxy - ## - extraEnv: {} - - ## Set to "-" to use default argument list - ## Otherwise convert to list of arguments - args: "-" - - ingress: enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - home-assistant.local - tls: [] - # - secretName: home-assistant-tls - # hosts: - # - home-assistant.local + # interval: 1m + # additionalLabels: {} - service: - type: ClusterIP - port: 80 - annotations: {} - labels: {} - clusterIP: "" - ## List of IP addresses at which the hass-vscode service is available - ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips - ## - externalIPs: [] - loadBalancerIP: "" - loadBalancerSourceRanges: [] - # nodePort: 30000 +persistence: + config: + enabled: false + emptyDir: false + ## Persistent Volume Storage Class + ## If defined, storageClassName: + ## 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: "-" + # accessMode: ReadWriteOnce + # size: 1Gi + ## Do not delete the pvc upon helm uninstall + # skipuninstall: false + # existingClaim: "" -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 +# # Path to your Z-Wave / Zigbee device in the container +# additionalVolumeMounts: +# - name: zwave-usb +# mountPath: /dev/serial/by-id/usb-0658_0200-if00 -nodeSelector: {} - -tolerations: [] - -affinity: {} - -podAnnotations: {} - -# Any extra volumes to define for the pod -extraVolumes: [] - # - name: example-name - # hostPath: - # path: /path/on/host - # type: DirectoryOrCreate - -# Any extra volume mounts to define for the containers -extraVolumeMounts: [] -# - name: example-name -# mountPath: /path/in/container +# # Path to your Z-Wave / Zigbee device on the host +# additionalVolumes: +# - name: zwave-usb +# hostPath: +# path: /dev/serial/by-id/usb-0658_0200-if00 # Enabled mariadb # ... for more options see https://github.com/bitnami/charts/tree/master/bitnami/mariadb