diff --git a/stable/home-assistant/Chart.yaml b/stable/home-assistant/Chart.yaml index 001df4d9c3e4..4bb987ffff94 100644 --- a/stable/home-assistant/Chart.yaml +++ b/stable/home-assistant/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 0.92.1 description: Home Assistant name: home-assistant -version: 0.8.0 +version: 0.9.0 keywords: - home-assistant - hass @@ -12,6 +12,7 @@ icon: https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Home_Assistant_L sources: - https://github.com/home-assistant/home-assistant - https://github.com/danielperna84/hass-configurator +- https://github.com/cdr/code-server maintainers: - name: billimek email: jeff@billimek.com diff --git a/stable/home-assistant/README.md b/stable/home-assistant/README.md index d7e29d280634..f059b8bc0700 100644 --- a/stable/home-assistant/README.md +++ b/stable/home-assistant/README.md @@ -96,6 +96,28 @@ The following tables lists the configurable parameters of the Home Assistant cha | `configurator.service.externalIPs` | External IPs for the configurator UI | `[]` | | `configurator.service.loadBalancerIP` | Loadbalancer IP for the configurator UI | `` | | `configurator.service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the configurator UI | `[]` | +| `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 | `1.939`| +| `vscode.image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `vscode.basepath` | Base path of the home assistant configuration files | `/config` | +| `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.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 | `[]` | | `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 | `[]` | @@ -121,7 +143,7 @@ Read through the [values.yaml](values.yaml) file. It has several commented out s 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, the [Home Assistant Configurator UI](https://github.com/danielperna84/hass-configurator) is added to the chart as an option to provide a webUI for editing the various configuration files. +Because this may be a limitation, the [Home Assistant Configurator UI](https://github.com/danielperna84/hass-configurator) and/or the [VS Code Server](https://github.com/cdr/code-server) are added to the chart as an option to provide a webUI for editing the various configuration files. ## Git sync secret diff --git a/stable/home-assistant/templates/deployment.yaml b/stable/home-assistant/templates/deployment.yaml index d16260a2ca5f..ce2cda52bdb4 100644 --- a/stable/home-assistant/templates/deployment.yaml +++ b/stable/home-assistant/templates/deployment.yaml @@ -52,6 +52,14 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.vscode.enabled }} + - name: init-vscode + image: appropriate/curl + command: ['sh', '-c', '[ -f /config/vscode/vscode-home-assistant-0.5.0-beta.4.vsix ] || mkdir -p /config/vscode && curl -s -L --retry 3 -o /config/vscode/vscode-home-assistant-0.5.0-beta.4.vsix "https://github.com/keesschollaart81/vscode-home-assistant/releases/download/v0.5.0-beta4/vscode-home-assistant-0.5.0-beta.4.vsix"'] + volumeMounts: + - mountPath: /config + name: config + {{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -178,6 +186,48 @@ spec: resources: {{ toYaml .Values.configurator.resources | indent 12 }} {{- end }} + {{- if .Values.vscode.enabled }} + - name: vscode + image: "{{ .Values.vscode.image.repository }}:{{ .Values.vscode.image.tag }}" + imagePullPolicy: {{ .Values.vscode.image.pullPolicy }} + workingDir: {{ .Values.vscode.basepath }} + args: + - --allow-http + - --port={{ .Values.vscode.service.port }} + # - --install-extension=/config/vscode/vscode-home-assistant-0.5.0-beta.4.vsix + {{- if not (.Values.vscode.password) }} + - --no-auth + {{- end }} + - --extensions-dir=/config/vscode + - --user-data-dir=/config/vscode + ports: + - name: http + containerPort: {{ .Values.vscode.service.port }} + protocol: TCP + env: + {{- if .Values.vscode.password }} + - name: PASSWORD + value: {{ .Values.vscode.password }} + {{- end }} + {{- range $key, $value := .Values.vscode.extraEnv }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + volumeMounts: + - mountPath: /config + name: config + {{- 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 }} diff --git a/stable/home-assistant/templates/service.yaml b/stable/home-assistant/templates/service.yaml index e34af3c0531d..ac6512fb0d93 100644 --- a/stable/home-assistant/templates/service.yaml +++ b/stable/home-assistant/templates/service.yaml @@ -52,6 +52,15 @@ spec: {{ if (and (eq .Values.configurator.service.type "NodePort") (not (empty .Values.configurator.service.nodePort))) }} nodePort: {{.Values.configurator.service.nodePort}} {{ end }} +{{- end }} +{{- if .Values.vscode.enabled }} + - name: http + port: {{ .Values.vscode.service.port }} + protocol: TCP + targetPort: 80 +{{ if (and (eq .Values.vscode.service.type "NodePort") (not (empty .Values.vscode.service.nodePort))) }} + nodePort: {{.Values.vscode.service.nodePort}} +{{ end }} {{- end }} selector: app.kubernetes.io/name: {{ include "home-assistant.name" . }} diff --git a/stable/home-assistant/templates/vscode-ingress.yaml b/stable/home-assistant/templates/vscode-ingress.yaml new file mode 100644 index 000000000000..8543cda193c0 --- /dev/null +++ b/stable/home-assistant/templates/vscode-ingress.yaml @@ -0,0 +1,39 @@ +{{- if (.Values.vscode.enabled) and (.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/stable/home-assistant/values.yaml b/stable/home-assistant/values.yaml index 6a9504587e0a..ea86e5b81005 100644 --- a/stable/home-assistant/values.yaml +++ b/stable/home-assistant/values.yaml @@ -151,6 +151,53 @@ configurator: loadBalancerSourceRanges: [] # nodePort: 30000 +vscode: + enabled: false + + ## code-server container image + ## + image: + repository: codercom/code-server + tag: 1.939 + pullPolicy: IfNotPresent + + ## VSCode password + # password: + ## path where the home assistant configuration is stored + basepath: /config + + ## Additional hass-vscode container environment variable + ## For instance to add a http_proxy + ## + extraEnv: {} + + 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 + + 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 + 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