Skip to content

Introduce extraInitContainers to helm chart #3393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Changelog

- [Changelog](#changelog)
- [Next Version](#next-version)
- [3.10.1](#3101)
- [Bug Fixes](#bug-fixes)
- [Documentation](#documentation)
Expand Down Expand Up @@ -51,6 +52,15 @@ VS Code v0.00.0

-->

## Next Version

VS Code v1.56.1

### New Features

- feat: supported `extraInitContainers` in helm chart values
- feat: changed `extraContainers` to support templating in helm chart

## 3.10.1

VS Code v1.56.1
Expand Down
45 changes: 45 additions & 0 deletions ci/helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ and their default values.
| extraArgs | list | `[]` | |
| extraConfigmapMounts | list | `[]` | |
| extraContainers | string | `""` | |
| extraInitContainers | string | `""` | |
| extraSecretMounts | list | `[]` | |
| extraVars | list | `[]` | |
| extraVolumeMounts | list | `[]` | |
Expand Down Expand Up @@ -115,3 +116,47 @@ $ helm upgrade --install code-server ci/helm-chart -f values.yaml
```

> **Tip**: You can use the default [values.yaml](values.yaml)

# Extra Containers

There are two parameters which allow to add more containers to pod.
Use `extraContainers` to add regular containers
and `extraInitContainers` to add init containers. You can read more
about init containers in [k8s documentation](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/).

Both parameters accept strings and use them as a templates

Example of using `extraInitContainers`:

``` yaml
extraInitContainers: |
- name: customization
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: IfNotPresent
env:
- name: SERVICE_URL
value: https://open-vsx.org/vscode/gallery
- name: ITEM_URL
value: https://open-vsx.org/vscode/item
command:
- sh
- -c
- |
code-server --install-extension ms-python.python
code-server --install-extension golang.Go
volumeMounts:
- name: data
mountPath: /home/coder

```

With this yaml in file `init.yaml`, you can execute

```console
$ helm upgrade --install code-server \
ci/helm-chart \
--values init.yaml
```

to deploy code-server with python and golang extensions preinstalled
before main container have started.
5 changes: 4 additions & 1 deletion ci/helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ spec:
volumeMounts:
- name: data
mountPath: /home/coder
{{- if .Values.extraInitContainers }}
{{ tpl .Values.extraInitContainers . | indent 6}}
{{- end }}
{{- end }}
containers:
{{- if .Values.extraContainers }}
{{ toYaml .Values.extraContainers | indent 8}}
{{ tpl .Values.extraContainers . | indent 8}}
{{- end }}
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down