Skip to content

Commit 1ffca57

Browse files
committed
introduce extraInitContainers to helm chart
New extraInitContainers configuration added. It allows to pass template with a list of containers to execute before main code-server container started. Main container will only start when all init containers are completed (exited with 0 code). Additionally changes the way extraContainers is used - instead of toYaml use tpl, because this allows to reference any values from extraContainers string.
1 parent 6e9e891 commit 1ffca57

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Changelog
44

55
- [Changelog](#changelog)
6+
- [Next Version](#next-version)
67
- [3.10.1](#3101)
78
- [Bug Fixes](#bug-fixes)
89
- [Documentation](#documentation)
@@ -51,6 +52,15 @@ VS Code v0.00.0
5152
5253
-->
5354

55+
## Next Version
56+
57+
VS Code v1.56.1
58+
59+
### New Features
60+
61+
- feat: supported `extraInitContainers` in helm chart values
62+
- feat: changed `extraContainers` to support templating in helm chart
63+
5464
## 3.10.1
5565

5666
VS Code v1.56.1

ci/helm-chart/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ and their default values.
6565
| extraArgs | list | `[]` | |
6666
| extraConfigmapMounts | list | `[]` | |
6767
| extraContainers | string | `""` | |
68+
| extraInitContainers | string | `""` | |
6869
| extraSecretMounts | list | `[]` | |
6970
| extraVars | list | `[]` | |
7071
| extraVolumeMounts | list | `[]` | |
@@ -115,3 +116,47 @@ $ helm upgrade --install code-server ci/helm-chart -f values.yaml
115116
```
116117

117118
> **Tip**: You can use the default [values.yaml](values.yaml)
119+
120+
# Extra Containers
121+
122+
There are two parameters which allow to add more containers to pod.
123+
Use `extraContainers` to add regular containers
124+
and `extraInitContainers` to add init containers. You can read more
125+
about init containers in [k8s documentation](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/).
126+
127+
Both parameters accept strings and use them as a templates
128+
129+
Example of using `extraInitContainers`:
130+
131+
``` yaml
132+
extraInitContainers: |
133+
- name: customization
134+
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
135+
imagePullPolicy: IfNotPresent
136+
env:
137+
- name: SERVICE_URL
138+
value: https://open-vsx.org/vscode/gallery
139+
- name: ITEM_URL
140+
value: https://open-vsx.org/vscode/item
141+
command:
142+
- sh
143+
- -c
144+
- |
145+
code-server --install-extension ms-python.python
146+
code-server --install-extension golang.Go
147+
volumeMounts:
148+
- name: data
149+
mountPath: /home/coder
150+
151+
```
152+
153+
With this yaml in file `init.yaml`, you can execute
154+
155+
```console
156+
$ helm upgrade --install code-server \
157+
ci/helm-chart \
158+
--values init.yaml
159+
```
160+
161+
to deploy code-server with python and golang extensions preinstalled
162+
before main container have started.

ci/helm-chart/templates/deployment.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ spec:
4343
volumeMounts:
4444
- name: data
4545
mountPath: /home/coder
46+
{{- if .Values.extraInitContainers }}
47+
{{ tpl .Values.extraInitContainers . | indent 6}}
48+
{{- end }}
4649
{{- end }}
4750
containers:
4851
{{- if .Values.extraContainers }}
49-
{{ toYaml .Values.extraContainers | indent 8}}
52+
{{ tpl .Values.extraContainers . | indent 8}}
5053
{{- end }}
5154
- name: {{ .Chart.Name }}
5255
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"

0 commit comments

Comments
 (0)