Skip to content

Commit 6ed1a15

Browse files
committed
refs coder#914: Helm chart
1 parent 8c39e08 commit 6ed1a15

13 files changed

+426
-0
lines changed

deployment/chart/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for code-server
4+
name: code-server
5+
version: 1.0.0

deployment/chart/README.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# code-server
2+
3+
[code-server](https://github.com/cdr/code-server) code-server is VS Code running on a remote server, accessible through the browser.
4+
5+
## TL;DR;
6+
7+
```console
8+
$ git clone https://github.com/cdr/code-server.git
9+
$ helm install deployment/chart
10+
```
11+
12+
## Introduction
13+
14+
This chart bootstraps a code-server deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
15+
16+
## Prerequisites
17+
18+
- Kubernetes 1.6+
19+
20+
## Installing the Chart
21+
22+
To install the chart with the release name `my-release`:
23+
24+
```console
25+
$ helm install --name my-release deployment/chart
26+
```
27+
28+
The command deploys code-server on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
29+
30+
> **Tip**: List all releases using `helm list`
31+
32+
## Uninstalling the Chart
33+
34+
To uninstall/delete the `my-release` deployment:
35+
36+
```console
37+
$ helm delete my-release
38+
```
39+
40+
The command removes all the Kubernetes components associated with the chart and deletes the release.
41+
42+
## Configuration
43+
44+
The following table lists the configurable parameters of the nginx-ingress chart and their default values.
45+
46+
47+
The following table lists the configurable parameters of the code-server chart and their default values.
48+
49+
| Parameter | Description | Default |
50+
| --------------------------------- | ------------------------------------------ | --------------------------------------------------------- |
51+
| `image.registry` | Code-server image registry | `docker.io` |
52+
| `image.repository` | Code-server Image name | `codercom/code-server` |
53+
| `image.tag` | Code-server Image tag | `{TAG_NAME}` |
54+
| `image.pullPolicy` | Code-server image pull policy | `IfNotPresent` |
55+
| `nameOverride` | String to partially override code-server.fullname template with a string (will prepend the release name) | `nil` |
56+
| `fullnameOverride` | String to fully override code-server.fullname template with a string |
57+
| `hostnameOverride` | String to fully override code-server container hostname |
58+
| `service.type` | Kubernetes Service type | `NodePort` |
59+
| `service.port` | Service HTTP port | `8443` |
60+
| `ingress.enabled` | Enable ingress controller resource | `false` |
61+
| `ingress.hosts[0].name` | Hostname to your code-server installation | `code-server.local` |
62+
| `ingress.hosts[0].path` | Path within the url structure | `/` |
63+
| `ingress.hosts[0].tls` | Utilize TLS backend in ingress | `false` |
64+
| `ingress.hosts[0].certManager` | Add annotations for cert-manager | `false` |
65+
| `ingress.hosts[0].tlsSecret` | TLS Secret (certificates) | `code-server.local-tls-secret` |
66+
| `ingress.hosts[0].annotations` | Annotations for this host's ingress record | `[]` |
67+
| `ingress.secrets[0].name` | TLS Secret Name | `nil` |
68+
| `ingress.secrets[0].certificate` | TLS Secret Certificate | `nil` |
69+
| `ingress.secrets[0].key` | TLS Secret Key | `nil` |
70+
| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` |
71+
| `persistence.enabled` | Enable persistence using PVC | `true` |
72+
| `persistence.storageClass` | PVC Storage Class for code-server volume | `nil` (uses alpha storage class annotation) |
73+
| `persistence.accessMode` | PVC Access Mode for code-server volume | `ReadWriteOnce` |
74+
| `persistence.size` | PVC Storage Request for code-server volume | `8Gi`
75+
76+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
77+
78+
```console
79+
$ helm install --name my-release \
80+
--set persistence.enabled=false \
81+
deployment/chart
82+
```
83+
84+
The above command sets the the persistence storage to false.
85+
86+
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
87+
88+
```console
89+
$ helm install --name my-release -f values.yaml deployment/chart
90+
```
91+
92+
> **Tip**: You can use the default [values.yaml](values.yaml)
93+
94+
## Image
95+
96+
The `image` parameter allows specifying which image will be pulled for the chart.

deployment/chart/templates/NOTES.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "code-server.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "code-server.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "code-server.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "code-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl port-forward $POD_NAME 8080:80
21+
{{- end }}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "code-server.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "code-server.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "code-server.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Create the name of the service account to use
36+
*/}}
37+
{{- define "code-server.serviceAccountName" -}}
38+
{{- if .Values.serviceAccount.create -}}
39+
{{ default (include "code-server.fullname" .) .Values.serviceAccount.name }}
40+
{{- else -}}
41+
{{ default "default" .Values.serviceAccount.name }}
42+
{{- end -}}
43+
{{- end -}}
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "code-server.fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: {{ include "code-server.name" . }}
7+
helm.sh/chart: {{ include "code-server.chart" . }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
spec:
11+
replicas: 1
12+
strategy:
13+
type: Recreate
14+
selector:
15+
matchLabels:
16+
app.kubernetes.io/name: {{ include "code-server.name" . }}
17+
app.kubernetes.io/instance: {{ .Release.Name }}
18+
template:
19+
metadata:
20+
labels:
21+
app.kubernetes.io/name: {{ include "code-server.name" . }}
22+
app.kubernetes.io/instance: {{ .Release.Name }}
23+
spec:
24+
{{- if .Values.hostnameOverride }}
25+
hostname: {{ .Values.hostnameOverride }}
26+
{{- end }}
27+
containers:
28+
- name: {{ .Chart.Name }}
29+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
30+
imagePullPolicy: {{ .Values.image.pullPolicy }}
31+
args: ["--allow-http", "--no-auth"]
32+
securityContext:
33+
runAsUser: 1000
34+
runAsGroup: 1000
35+
fsGroup: 1000
36+
volumeMounts:
37+
- name: data
38+
mountPath: /home/coder/project
39+
subPath: project
40+
- name: data
41+
mountPath: /home/coder/.local/share/code-server
42+
subPath: code-server
43+
ports:
44+
- name: http
45+
containerPort: 8443
46+
protocol: TCP
47+
livenessProbe:
48+
httpGet:
49+
path: /
50+
port: http
51+
readinessProbe:
52+
httpGet:
53+
path: /
54+
port: http
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
{{- with .Values.nodeSelector }}
58+
nodeSelector:
59+
{{- toYaml . | nindent 8 }}
60+
{{- end }}
61+
{{- with .Values.affinity }}
62+
affinity:
63+
{{- toYaml . | nindent 8 }}
64+
{{- end }}
65+
{{- with .Values.tolerations }}
66+
tolerations:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
serviceAccountName: {{ template "code-server.serviceAccountName" . }}
70+
volumes:
71+
- name: data
72+
{{- if .Values.persistence.enabled }}
73+
persistentVolumeClaim:
74+
claimName: {{ .Values.persistence.existingClaim | default (include "code-server.fullname" .) }}
75+
{{- else }}
76+
emptyDir: {}
77+
{{- end -}}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "code-server.fullname" . -}}
3+
apiVersion: extensions/v1beta1
4+
kind: Ingress
5+
metadata:
6+
name: {{ $fullName }}
7+
labels:
8+
app.kubernetes.io/name: {{ include "code-server.name" . }}
9+
helm.sh/chart: {{ include "code-server.chart" . }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
app.kubernetes.io/managed-by: {{ .Release.Service }}
12+
{{- with .Values.ingress.annotations }}
13+
annotations:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
{{- if .Values.ingress.tls }}
18+
tls:
19+
{{- range .Values.ingress.tls }}
20+
- hosts:
21+
{{- range .hosts }}
22+
- {{ . | quote }}
23+
{{- end }}
24+
secretName: {{ .secretName }}
25+
{{- end }}
26+
{{- end }}
27+
rules:
28+
{{- range .Values.ingress.hosts }}
29+
- host: {{ .host | quote }}
30+
http:
31+
paths:
32+
{{- range .paths }}
33+
- path: {{ . }}
34+
backend:
35+
serviceName: {{ $fullName }}
36+
servicePort: http
37+
{{- end }}
38+
{{- end }}
39+
{{- end }}

deployment/chart/templates/pvc.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: {{ include "code-server.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
{{- with .Values.persistence.annotations }}
8+
annotations:
9+
{{ toYaml . | indent 4 }}
10+
{{- end }}
11+
labels:
12+
app.kubernetes.io/name: {{ include "code-server.name" . }}
13+
helm.sh/chart: {{ include "code-server.chart" . }}
14+
app.kubernetes.io/instance: {{ .Release.Name }}
15+
app.kubernetes.io/managed-by: {{ .Release.Service }}
16+
spec:
17+
accessModes:
18+
- {{ .Values.persistence.accessMode | quote }}
19+
resources:
20+
requests:
21+
storage: {{ .Values.persistence.size | quote }}
22+
{{- if .Values.persistence.storageClass }}
23+
{{- if (eq "-" .Values.persistence.storageClass) }}
24+
storageClassName: ""
25+
{{- else }}
26+
storageClassName: "{{ .Values.persistence.storageClass }}"
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "code-server.fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: {{ include "code-server.name" . }}
7+
helm.sh/chart: {{ include "code-server.chart" . }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
spec:
11+
type: {{ .Values.service.type }}
12+
ports:
13+
- port: {{ .Values.service.port }}
14+
targetPort: http
15+
protocol: TCP
16+
name: http
17+
selector:
18+
app.kubernetes.io/name: {{ include "code-server.name" . }}
19+
app.kubernetes.io/instance: {{ .Release.Name }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if or .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: {{ include "code-server.name" . }}
7+
helm.sh/chart: {{ include "code-server.chart" . }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
name: {{ template "code-server.serviceAccountName" . }}
11+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "code-server.fullname" . }}-test-connection"
5+
labels:
6+
app.kubernetes.io/name: {{ include "code-server.name" . }}
7+
helm.sh/chart: {{ include "code-server.chart" . }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
annotations:
11+
"helm.sh/hook": test-success
12+
spec:
13+
containers:
14+
- name: wget
15+
image: busybox
16+
command: ['wget']
17+
args: ['{{ include "code-server.fullname" . }}:{{ .Values.service.port }}']
18+
restartPolicy: Never

0 commit comments

Comments
 (0)