Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
support for optional VS Code server sidecar
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Billimek <jeff@billimek.com>
  • Loading branch information
billimek committed May 6, 2019
1 parent 8055bd2 commit 01e3593
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 2 deletions.
3 changes: 2 additions & 1 deletion stable/home-assistant/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
24 changes: 23 additions & 1 deletion stable/home-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `[]` |
Expand All @@ -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

Expand Down
50 changes: 50 additions & 0 deletions stable/home-assistant/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}
Expand Down
9 changes: 9 additions & 0 deletions stable/home-assistant/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand Down
39 changes: 39 additions & 0 deletions stable/home-assistant/templates/vscode-ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
47 changes: 47 additions & 0 deletions stable/home-assistant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01e3593

Please sign in to comment.