From cef293ea4ea4a5df6a3751b4009de185944ba538 Mon Sep 17 00:00:00 2001 From: Jeff Billimek Date: Sun, 16 Sep 2018 13:53:33 -0400 Subject: [PATCH] [stable/home-assistant] OWNERS and convert configurator to sidecar (#7448) * adding OWNERS file Signed-off-by: Jeff Billimek * changes to make configurator run as a sidecar Signed-off-by: Jeff Billimek * making chart version semver Signed-off-by: Jeff Billimek * removing ready and live checks to see if this fixes failing E2E tests Signed-off-by: Jeff Billimek * Revert "removing ready and live checks to see if this fixes failing E2E tests" This reverts commit 22d99d60f1cdf90b18c1c48fdcfb575e2c63a414. Signed-off-by: Jeff Billimek * correcting syntax issue with pvc template Signed-off-by: Jeff Billimek * do not need ReadWriteMany anymore Signed-off-by: Jeff Billimek --- stable/home-assistant/.helmignore | 2 + stable/home-assistant/Chart.yaml | 4 +- stable/home-assistant/OWNERS | 4 + .../templates/configurator-deployment.yaml | 107 ------------------ .../templates/configurator-ingress.yaml | 5 +- .../templates/configurator-svc.yaml | 53 --------- .../home-assistant/templates/deployment.yaml | 70 +++++++++++- stable/home-assistant/templates/ingress.yaml | 3 +- stable/home-assistant/templates/pvc.yaml | 5 +- .../{configurator-secret.yaml => secret.yaml} | 3 +- stable/home-assistant/templates/service.yaml | 15 ++- stable/home-assistant/values.yaml | 91 ++------------- 12 files changed, 103 insertions(+), 259 deletions(-) create mode 100644 stable/home-assistant/OWNERS delete mode 100644 stable/home-assistant/templates/configurator-deployment.yaml delete mode 100644 stable/home-assistant/templates/configurator-svc.yaml rename stable/home-assistant/templates/{configurator-secret.yaml => secret.yaml} (93%) diff --git a/stable/home-assistant/.helmignore b/stable/home-assistant/.helmignore index f0c1319444..a9fe727881 100644 --- a/stable/home-assistant/.helmignore +++ b/stable/home-assistant/.helmignore @@ -19,3 +19,5 @@ .project .idea/ *.tmproj +# OWNERS file for Kubernetes +OWNERS \ No newline at end of file diff --git a/stable/home-assistant/Chart.yaml b/stable/home-assistant/Chart.yaml index d1828282a2..4ccc5aa3dd 100644 --- a/stable/home-assistant/Chart.yaml +++ b/stable/home-assistant/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 -appVersion: 0.74.2 +appVersion: 0.77.1 description: Home Assistant name: home-assistant -version: 0.1.45 +version: 0.2.0 keywords: - home-assistant - hass diff --git a/stable/home-assistant/OWNERS b/stable/home-assistant/OWNERS new file mode 100644 index 0000000000..b90909f487 --- /dev/null +++ b/stable/home-assistant/OWNERS @@ -0,0 +1,4 @@ +approvers: +- billimek +reviewers: +- billimek diff --git a/stable/home-assistant/templates/configurator-deployment.yaml b/stable/home-assistant/templates/configurator-deployment.yaml deleted file mode 100644 index 9f5433805f..0000000000 --- a/stable/home-assistant/templates/configurator-deployment.yaml +++ /dev/null @@ -1,107 +0,0 @@ - -{{- if .Values.configurator.enabled -}} -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: {{ template "home-assistant.fullname" . }}-configurator - labels: - app: {{ template "home-assistant.name" . }} - chart: {{ template "home-assistant.chart" . }} - component: configurator - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.configurator.replicaCount }} - selector: - matchLabels: - app: {{ template "home-assistant.name" . }} - release: {{ .Release.Name }} - component: configurator - template: - metadata: - labels: - app: {{ template "home-assistant.name" . }} - component: configurator - release: {{ .Release.Name }} - spec: - containers: - - name: {{ template "home-assistant.name" . }}-configurator - image: "{{ .Values.configurator.image.repository }}:{{ .Values.configurator.image.tag }}" - imagePullPolicy: {{ .Values.configurator.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.configurator.service.port }} - protocol: TCP - livenessProbe: - tcpSocket: - port: http - initialDelaySeconds: 30 - readinessProbe: - tcpSocket: - port: http - initialDelaySeconds: 15 - env: - {{- if .Values.configurator.hassApiPassword }} - - name: HC_HASS_API_PASSWORD - valueFrom: - secretKeyRef: - name: {{ template "home-assistant.fullname" . }}-configurator - key: hass-api-password - {{- end }} - {{- if (.Values.configurator.username) and (.Values.configurator.password) }} - - name: HC_USERNAME - valueFrom: - secretKeyRef: - name: {{ template "home-assistant.fullname" . }}-configurator - key: username - - name: HC_PASSWORD - valueFrom: - secretKeyRef: - name: {{ template "home-assistant.fullname" . }}-configurator - key: password - {{- end }} - {{- if .Values.configurator.hassApiUrl }} - - name: HC_HASS_API - value: "{{ .Values.configurator.hassApiUrl }}" - {{- else }} - - name: HC_HASS_API - value: "http://{{ template "home-assistant.fullname" . }}:{{ .Values.service.port }}/api/" - {{- end }} - {{- if .Values.configurator.basepath }} - - name: HC_BASEPATH - value: "{{ .Values.configurator.basepath }}" - {{- end }} - {{- if .Values.configurator.enforceBasepath }} - - name: HC_ENFORCE_BASEPATH - value: "{{ .Values.configurator.enforceBasepath }}" - {{- end }} - {{- range $key, $value := .Values.configurator.extraEnv }} - - name: {{ $key }} - value: {{ $value }} - {{- end }} - volumeMounts: - - mountPath: /config - name: config - resources: -{{ toYaml .Values.configurator.resources | indent 12 }} - volumes: - - name: config - {{- if .Values.persistence.enabled }} - persistentVolumeClaim: - claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "home-assistant.fullname" . }}{{- end }} - {{- else }} - emptyDir: {} - {{ end }} - {{- with .Values.configurator.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.configurator.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.configurator.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/stable/home-assistant/templates/configurator-ingress.yaml b/stable/home-assistant/templates/configurator-ingress.yaml index 33c3217be3..6f67bce15c 100644 --- a/stable/home-assistant/templates/configurator-ingress.yaml +++ b/stable/home-assistant/templates/configurator-ingress.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.configurator.enabled .Values.configurator.ingress.enabled -}} +{{- if (.Values.configurator.enabled) and (.Values.configurator.ingress.enabled) }} {{- $fullName := include "home-assistant.fullname" . -}} {{- $servicePort := .Values.configurator.service.port -}} {{- $ingressPath := .Values.configurator.ingress.path -}} @@ -9,7 +9,6 @@ metadata: labels: app: {{ template "home-assistant.name" . }} chart: {{ template "home-assistant.chart" . }} - component: configurator release: {{ .Release.Name }} heritage: {{ .Release.Service }} {{- with .Values.configurator.ingress.annotations }} @@ -34,7 +33,7 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }}-configurator + serviceName: {{ $fullName }} servicePort: {{ $servicePort }} {{- end }} {{- end }} diff --git a/stable/home-assistant/templates/configurator-svc.yaml b/stable/home-assistant/templates/configurator-svc.yaml deleted file mode 100644 index faeea5cf73..0000000000 --- a/stable/home-assistant/templates/configurator-svc.yaml +++ /dev/null @@ -1,53 +0,0 @@ -{{- if .Values.configurator.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ template "home-assistant.fullname" . }}-configurator - labels: - app: {{ template "home-assistant.name" . }} - chart: {{ template "home-assistant.chart" . }} - component: configurator - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- if .Values.configurator.service.labels }} -{{ toYaml .Values.configurator.service.labels | indent 4 }} -{{- end }} -{{- with .Values.configurator.service.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if (or (eq .Values.configurator.service.type "ClusterIP") (empty .Values.configurator.service.type)) }} - type: ClusterIP - {{- if .Values.configurator.service.clusterIP }} - clusterIP: {{ .Values.configurator.service.clusterIP }} - {{end}} -{{- else if eq .Values.configurator.service.type "LoadBalancer" }} - type: {{ .Values.configurator.service.type }} - {{- if .Values.configurator.service.loadBalancerIP }} - loadBalancerIP: {{ .Values.configurator.service.loadBalancerIP }} - {{- end }} - {{- if .Values.configurator.service.loadBalancerSourceRanges }} - loadBalancerSourceRanges: -{{ toYaml .Values.configurator.service.loadBalancerSourceRanges | indent 4 }} - {{- end -}} -{{- else }} - type: {{ .Values.configurator.service.type }} -{{- end }} -{{- if .Values.configurator.service.externalIPs }} - externalIPs: -{{ toYaml .Values.configurator.service.externalIPs | indent 4 }} -{{- end }} - ports: - - name: http - port: {{ .Values.configurator.service.port }} - protocol: TCP - targetPort: 3218 -{{ if (and (eq .Values.configurator.service.type "NodePort") (not (empty .Values.configurator.service.nodePort))) }} - nodePort: {{.Values.configurator.service.nodePort}} -{{ end }} - selector: - app: {{ template "home-assistant.name" . }} - release: {{ .Release.Name }} - component: configurator -{{- end }} \ No newline at end of file diff --git a/stable/home-assistant/templates/deployment.yaml b/stable/home-assistant/templates/deployment.yaml index 82349cede3..4d677ae457 100644 --- a/stable/home-assistant/templates/deployment.yaml +++ b/stable/home-assistant/templates/deployment.yaml @@ -5,7 +5,6 @@ metadata: labels: app: {{ template "home-assistant.name" . }} chart: {{ template "home-assistant.chart" . }} - component: server release: {{ .Release.Name }} heritage: {{ .Release.Service }} spec: @@ -14,31 +13,29 @@ spec: matchLabels: app: {{ template "home-assistant.name" . }} release: {{ .Release.Name }} - component: server template: metadata: labels: app: {{ template "home-assistant.name" . }} release: {{ .Release.Name }} - component: server spec: containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - - name: http + - name: api containerPort: {{ .Values.service.port }} protocol: TCP livenessProbe: httpGet: path: / - port: http + port: api initialDelaySeconds: 30 readinessProbe: httpGet: path: / - port: http + port: api initialDelaySeconds: 15 env: {{- range $key, $value := .Values.extraEnv }} @@ -50,6 +47,67 @@ spec: name: config resources: {{ toYaml .Values.resources | indent 12 }} + {{- if .Values.configurator.enabled }} + - name: configurator + image: "{{ .Values.configurator.image.repository }}:{{ .Values.configurator.image.tag }}" + imagePullPolicy: {{ .Values.configurator.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.configurator.service.port }} + protocol: TCP + livenessProbe: + tcpSocket: + port: http + initialDelaySeconds: 30 + readinessProbe: + tcpSocket: + port: http + initialDelaySeconds: 15 + env: + {{- if .Values.configurator.hassApiPassword }} + - name: HC_HASS_API_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "home-assistant.fullname" . }}-configurator + key: hass-api-password + {{- end }} + {{- if (.Values.configurator.username) and (.Values.configurator.password) }} + - name: HC_USERNAME + valueFrom: + secretKeyRef: + name: {{ template "home-assistant.fullname" . }}-configurator + key: username + - name: HC_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "home-assistant.fullname" . }}-configurator + key: password + {{- end }} + {{- if .Values.configurator.hassApiUrl }} + - name: HC_HASS_API + value: "{{ .Values.configurator.hassApiUrl }}" + {{- else }} + - name: HC_HASS_API + value: "http://{{ template "home-assistant.fullname" . }}:{{ .Values.service.port }}/api/" + {{- end }} + {{- if .Values.configurator.basepath }} + - name: HC_BASEPATH + value: "{{ .Values.configurator.basepath }}" + {{- end }} + {{- if .Values.configurator.enforceBasepath }} + - name: HC_ENFORCE_BASEPATH + value: "{{ .Values.configurator.enforceBasepath }}" + {{- end }} + {{- range $key, $value := .Values.configurator.extraEnv }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + volumeMounts: + - mountPath: /config + name: config + resources: +{{ toYaml .Values.configurator.resources | indent 12 }} + {{- end }} volumes: - name: config {{- if .Values.persistence.enabled }} diff --git a/stable/home-assistant/templates/ingress.yaml b/stable/home-assistant/templates/ingress.yaml index a7b5e69701..936d8a6386 100644 --- a/stable/home-assistant/templates/ingress.yaml +++ b/stable/home-assistant/templates/ingress.yaml @@ -9,7 +9,6 @@ metadata: labels: app: {{ template "home-assistant.name" . }} chart: {{ template "home-assistant.chart" . }} - component: server release: {{ .Release.Name }} heritage: {{ .Release.Service }} {{- with .Values.ingress.annotations }} @@ -35,6 +34,6 @@ spec: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} - servicePort: http + servicePort: {{ $servicePort }} {{- end }} {{- end }} diff --git a/stable/home-assistant/templates/pvc.yaml b/stable/home-assistant/templates/pvc.yaml index f6317f0827..b5d89da135 100644 --- a/stable/home-assistant/templates/pvc.yaml +++ b/stable/home-assistant/templates/pvc.yaml @@ -1,4 +1,5 @@ -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +{{- if .Values.persistence.enabled -}} +{{- if not .Values.persistence.existingClaim -}} kind: PersistentVolumeClaim apiVersion: v1 metadata: @@ -6,7 +7,6 @@ metadata: labels: app: {{ template "home-assistant.fullname" . }} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - component: server release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: @@ -22,4 +22,5 @@ spec: storageClassName: "{{ .Values.persistence.storageClass }}" {{- end }} {{- end }} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/stable/home-assistant/templates/configurator-secret.yaml b/stable/home-assistant/templates/secret.yaml similarity index 93% rename from stable/home-assistant/templates/configurator-secret.yaml rename to stable/home-assistant/templates/secret.yaml index 3305d62bd7..a48f055e80 100644 --- a/stable/home-assistant/templates/configurator-secret.yaml +++ b/stable/home-assistant/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- if .Values.configurator.enabled }} apiVersion: v1 kind: Secret metadata: @@ -5,7 +6,6 @@ metadata: labels: app: {{ template "home-assistant.name" . }} chart: {{ template "home-assistant.chart" . }} - component: configurator release: {{ .Release.Name }} heritage: {{ .Release.Service }} type: Opaque @@ -19,3 +19,4 @@ data: {{- if .Values.configurator.password }} password: {{ .Values.configurator.password | b64enc | quote }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/stable/home-assistant/templates/service.yaml b/stable/home-assistant/templates/service.yaml index 04df3c23d6..3fa9f08a35 100644 --- a/stable/home-assistant/templates/service.yaml +++ b/stable/home-assistant/templates/service.yaml @@ -5,7 +5,6 @@ metadata: labels: app: {{ template "home-assistant.name" . }} chart: {{ template "home-assistant.chart" . }} - component: server release: {{ .Release.Name }} heritage: {{ .Release.Service }} {{- if .Values.service.labels }} @@ -38,14 +37,22 @@ spec: {{ toYaml .Values.service.externalIPs | indent 4 }} {{- end }} ports: - - name: http + - name: api 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.configurator.enabled }} + - name: http + port: {{ .Values.configurator.service.port }} + protocol: TCP + targetPort: 3218 +{{ if (and (eq .Values.configurator.service.type "NodePort") (not (empty .Values.configurator.service.nodePort))) }} + nodePort: {{.Values.configurator.service.nodePort}} +{{ end }} +{{- end }} selector: app: {{ template "home-assistant.name" . }} - release: {{ .Release.Name }} - component: server \ No newline at end of file + release: {{ .Release.Name }} \ No newline at end of file diff --git a/stable/home-assistant/values.yaml b/stable/home-assistant/values.yaml index b1fbb7e2a2..65adff65c8 100644 --- a/stable/home-assistant/values.yaml +++ b/stable/home-assistant/values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 image: repository: homeassistant/home-assistant - tag: 0.74.2 + tag: 0.77.1 pullPolicy: IfNotPresent service: @@ -50,7 +50,7 @@ persistence: ## If you want to reuse an existing claim, you can pass the name of the PVC using ## the existingClaim variable # existingClaim: your-claim - accessMode: ReadWriteMany + accessMode: ReadWriteOnce size: 5Gi ## Additional hass-configurator container environment variable @@ -88,86 +88,21 @@ configurator: extraEnv: {} ingress: - ## If true, hass-configurator Ingress will be created - ## enabled: false - - ## hass-configurator Ingress annotations - ## annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: 'true' - - ## hass-configurator Ingress hostnames with optional path - ## Must be provided if Ingress is enabled - ## - hosts: [] - # - hass-configurator.domain.com - # - domain.com/hass-configurator - - ## hass-configurator Ingress TLS configuration - ## Secrets must be manually created in the namespace - ## + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - home-assistant.local tls: [] - # - secretName: hass-configurator-tls - # hosts: - # - hass-configurator.domain.com - - ## hass-configurator Deployment Strategy type - # strategy: - # type: Recreate - - ## Node tolerations for hass-configurator scheduling to nodes with taints - ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - ## - tolerations: [] - # - key: "key" - # operator: "Equal|Exists" - # value: "value" - # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" - - ## Node labels for hass-configurator pod assignment - ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ - ## - nodeSelector: {} - - ## Use an alternate scheduler, e.g. "stork". - ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/ - ## - # schedulerName: - - ## Annotations to be added to hass-configurator pods - ## - podAnnotations: {} - - replicaCount: 1 - - ## hass-configurator resource requests and limits - ## Ref: http://kubernetes.io/docs/user-guide/compute-resources/ - ## - resources: {} - # limits: - # cpu: 10m - # memory: 32Mi - # requests: - # cpu: 10m - # memory: 32Mi - - ## Security context to be added to hass-configurator pods - ## - securityContext: {} + # - secretName: home-assistant-tls + # hosts: + # - home-assistant.local service: type: ClusterIP port: 3218 - ## Specify the nodePort value for the LoadBalancer and NodePort service types. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport - ## - # nodePort: - ## Provide any additional annotations which may be required. This can be used to - ## set the LoadBalancer service type to internal only. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer - ## annotations: {} labels: {} clusterIP: "" @@ -175,11 +110,9 @@ configurator: ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips ## externalIPs: [] - ## Use loadBalancerIP to request a specific static IP, - ## otherwise leave blank - ## - loadBalancerIP: + loadBalancerIP: "" loadBalancerSourceRanges: [] + # nodePort: 30000 resources: {} # We usually recommend not to specify default resources and to leave this as a conscious