Skip to content

Commit

Permalink
feat(code-server): allow cloning repositories before container start
Browse files Browse the repository at this point in the history
  • Loading branch information
pascaliske committed Sep 19, 2021
1 parent 635973d commit 0a4a1ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/code-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
type: application
name: code-server
description: A Helm chart for Kubernetes
version: 0.0.1
version: 0.0.2
appVersion: "v3.12.0"

home: https://github.com/pascaliske/helm-charts/tree/master/charts/code-server
Expand Down
2 changes: 1 addition & 1 deletion charts/code-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> A Helm chart for Kubernetes
[![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)[![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)[![AppVersion: v3.12.0](https://img.shields.io/badge/AppVersion-v3.12.0-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)
[![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)[![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)[![AppVersion: v3.12.0](https://img.shields.io/badge/AppVersion-v3.12.0-informational?style=flat-square) ](https://github.com/pascaliske/helm-charts/tree/master/charts/code-server)

* <https://github.com/pascaliske/helm-charts>
* <https://github.com/cdr/code-server>
Expand Down
23 changes: 15 additions & 8 deletions charts/code-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- if .Values.deployment.enabled -}}
{{- if empty .Values.persistentVolumeClaim.projectsPath -}}
{{- fail "Empty projects path detected in \".Values.persistentVolumeClaim.projectsPath\"!" -}}
{{- end -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -29,21 +32,27 @@ spec:
{{- include "code-server.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "code-server.serviceAccountName" . }}
{{- if .Values.persistentVolumeClaim.ensurePermissions }}
initContainers:
{{- if .Values.persistentVolumeClaim.ensurePermissions }}
- name: {{ printf "%s-permissions" (include "code-server.fullname" .) }}
image: busybox:latest
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.runAsGroup }} {{ .Values.persistentVolumeClaim.mountPath }}
command: ['sh', '-c', 'chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.runAsGroup }} {{ .Values.persistentVolumeClaim.mountPath }}']
volumeMounts:
- name: storage-volume
mountPath: {{ .Values.persistentVolumeClaim.mountPath }}
securityContext:
runAsUser: 0
{{- end }}
{{- end }}
{{- range $i, $repo := .Values.repositories }}
- name: {{ printf "%s-clone" (include "code-server.fullname" $) }}
image: alpine/git:latest
imagePullPolicy: IfNotPresent
args: ['clone', '{{ $repo }}', '{{ $.Values.persistentVolumeClaim.projectsPath }}']
volumeMounts:
- name: storage-volume
mountPath: {{ $.Values.persistentVolumeClaim.mountPath }}
{{- end }}
containers:
- name: {{ template "code-server.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down Expand Up @@ -88,9 +97,7 @@ spec:
{{- range $i, $val := .Values.extraArgs }}
- {{ $val }}
{{- end }}
{{- if not (empty .Values.persistentVolumeClaim.projectsPath) }}
workingDir: {{ .Values.persistentVolumeClaim.projectsPath }}
{{- end }}
volumeMounts:
- name: config-volume
mountPath: {{ .Values.configMap.mountPath }}
Expand Down
3 changes: 3 additions & 0 deletions charts/code-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ persistentVolumeClaim:
annotations: {}
labels: {}

repositories: []
# - https://github.com/pascaliske/helm-charts

serviceAccount:
name: ''

Expand Down

0 comments on commit 0a4a1ae

Please sign in to comment.