Skip to content

Commit 0f1bbc3

Browse files
authored
Merge pull request #917 from paolomainardi/master
#914 - New helm chart for v1
2 parents 8c39e08 + 615948c commit 0f1bbc3

14 files changed

+601
-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

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

deployment/chart/templates/NOTES.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 }}
22+
23+
Administrator credentials:
24+
25+
Password : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "code-server.fullname" . }} -o jsonpath="{.data.password}" | base64 --decode)
+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 -}}
+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
{{- if .Values.securityContext.enabled }}
28+
securityContext:
29+
fsGroup: {{ .Values.securityContext.fsGroup }}
30+
{{- end }}
31+
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
32+
initContainers:
33+
- name: init-chmod-data
34+
image: busybox:latest
35+
imagePullPolicy: IfNotPresent
36+
command:
37+
- sh
38+
- -c
39+
- |
40+
chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /home/coder
41+
securityContext:
42+
runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }}
43+
volumeMounts:
44+
- name: data
45+
mountPath: /home/coder
46+
{{- end }}
47+
containers:
48+
{{- if .Values.extraContainers }}
49+
{{ toYaml .Values.extraContainers | indent 8}}
50+
{{- end }}
51+
- name: {{ .Chart.Name }}
52+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
53+
imagePullPolicy: {{ .Values.image.pullPolicy }}
54+
{{- if .Values.securityContext.enabled }}
55+
securityContext:
56+
runAsUser: {{ .Values.securityContext.runAsUser }}
57+
{{- end }}
58+
env:
59+
{{- if .Values.extraVars }}
60+
{{ toYaml .Values.extraVars | indent 10 }}
61+
{{- end }}
62+
- name: PASSWORD
63+
valueFrom:
64+
secretKeyRef:
65+
{{- if .Values.existingSecret }}
66+
name: {{ .Values.existingSecret }}
67+
{{- else }}
68+
name: {{ template "code-server.fullname" . }}
69+
{{- end }}
70+
key: password
71+
{{- if .Values.extraArgs }}
72+
args:
73+
{{ toYaml .Values.extraArgs | indent 10 }}
74+
{{- end }}
75+
volumeMounts:
76+
- name: data
77+
mountPath: /home/coder/project
78+
subPath: project
79+
- name: data
80+
mountPath: /home/coder/.local/share/code-server
81+
subPath: code-server
82+
{{- range .Values.extraConfigmapMounts }}
83+
- name: {{ .name }}
84+
mountPath: {{ .mountPath }}
85+
subPath: {{ .subPath | default "" }}
86+
readOnly: {{ .readOnly }}
87+
{{- end }}
88+
{{- range .Values.extraSecretMounts }}
89+
- name: {{ .name }}
90+
mountPath: {{ .mountPath }}
91+
readOnly: {{ .readOnly }}
92+
{{- end }}
93+
{{- range .Values.extraVolumeMounts }}
94+
- name: {{ .name }}
95+
mountPath: {{ .mountPath }}
96+
subPath: {{ .subPath | default "" }}
97+
readOnly: {{ .readOnly }}
98+
{{- end }}
99+
ports:
100+
- name: http
101+
containerPort: 8443
102+
protocol: TCP
103+
livenessProbe:
104+
httpGet:
105+
path: /
106+
port: http
107+
readinessProbe:
108+
httpGet:
109+
path: /
110+
port: http
111+
resources:
112+
{{- toYaml .Values.resources | nindent 12 }}
113+
{{- with .Values.nodeSelector }}
114+
nodeSelector:
115+
{{- toYaml . | nindent 8 }}
116+
{{- end }}
117+
{{- with .Values.affinity }}
118+
affinity:
119+
{{- toYaml . | nindent 8 }}
120+
{{- end }}
121+
{{- with .Values.tolerations }}
122+
tolerations:
123+
{{- toYaml . | nindent 8 }}
124+
{{- end }}
125+
serviceAccountName: {{ template "code-server.serviceAccountName" . }}
126+
volumes:
127+
- name: data
128+
{{- if .Values.persistence.enabled }}
129+
persistentVolumeClaim:
130+
claimName: {{ .Values.persistence.existingClaim | default (include "code-server.fullname" .) }}
131+
{{- else }}
132+
emptyDir: {}
133+
{{- end -}}
134+
{{- range .Values.extraSecretMounts }}
135+
- name: {{ .name }}
136+
secret:
137+
secretName: {{ .secretName }}
138+
defaultMode: {{ .defaultMode }}
139+
{{- end }}
140+
{{- range .Values.extraVolumeMounts }}
141+
- name: {{ .name }}
142+
persistentVolumeClaim:
143+
claimName: {{ .existingClaim }}
144+
{{- 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 }}

0 commit comments

Comments
 (0)