From b4fd47b5af431e2d2f6daea4e89ed841e72c498f Mon Sep 17 00:00:00 2001 From: Hossam Hammady Date: Mon, 12 Oct 2020 11:59:53 +0000 Subject: [PATCH 1/2] Add support for hostPath volumes --- charts/code-server/templates/deployment.yaml | 26 ++++++++++++++------ charts/code-server/templates/pvc.yaml | 2 +- charts/code-server/values.yaml | 2 ++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/charts/code-server/templates/deployment.yaml b/charts/code-server/templates/deployment.yaml index 60caa330..e1036291 100644 --- a/charts/code-server/templates/deployment.yaml +++ b/charts/code-server/templates/deployment.yaml @@ -126,19 +126,31 @@ spec: volumes: - name: data {{- if .Values.persistence.enabled }} + {{- if not .Values.persistence.hostPath }} persistentVolumeClaim: claimName: {{ .Values.persistence.existingClaim | default (include "code-server.fullname" .) }} + {{- else }} + hostPath: + path: {{ .Values.persistence.hostPath }} + type: Directory + {{- end -}} {{- else }} emptyDir: {} {{- end -}} {{- range .Values.extraSecretMounts }} - - name: {{ .name }} - secret: - secretName: {{ .secretName }} - defaultMode: {{ .defaultMode }} + - name: {{ .name }} + secret: + secretName: {{ .secretName }} + defaultMode: {{ .defaultMode }} {{- end }} {{- range .Values.extraVolumeMounts }} - - name: {{ .name }} - persistentVolumeClaim: - claimName: {{ .existingClaim }} + - name: {{ .name }} + {{- if .existingClaim }} + persistentVolumeClaim: + claimName: {{ .existingClaim }} + {{- else }} + hostPath: + path: {{ .hostPath }} + type: Directory + {{- end }} {{- end }} diff --git a/charts/code-server/templates/pvc.yaml b/charts/code-server/templates/pvc.yaml index f2930147..2f1c8740 100644 --- a/charts/code-server/templates/pvc.yaml +++ b/charts/code-server/templates/pvc.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +{{- if and (and .Values.persistence.enabled (not .Values.persistence.existingClaim)) (not .Values.persistence.hostPath) }} kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/charts/code-server/values.yaml b/charts/code-server/values.yaml index 18211654..eff18035 100644 --- a/charts/code-server/values.yaml +++ b/charts/code-server/values.yaml @@ -115,6 +115,7 @@ persistence: size: 1Gi annotations: {} # existingClaim: "" + # hostPath: /data serviceAccount: create: true @@ -152,6 +153,7 @@ extraVolumeMounts: [] # mountPath: /mnt/volume # readOnly: true # existingClaim: volume-claim + # hostPath: "" extraConfigmapMounts: [] # - name: certs-configmap From 83465a2f4f8475b3c7ff2b3665066ed1fcc9f414 Mon Sep 17 00:00:00 2001 From: Hossam Hammady Date: Mon, 12 Oct 2020 12:50:43 +0000 Subject: [PATCH 2/2] Simplify data volume mount --- charts/code-server/templates/deployment.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/charts/code-server/templates/deployment.yaml b/charts/code-server/templates/deployment.yaml index e1036291..9364a470 100644 --- a/charts/code-server/templates/deployment.yaml +++ b/charts/code-server/templates/deployment.yaml @@ -74,11 +74,7 @@ spec: {{- end }} volumeMounts: - name: data - mountPath: /home/coder/project - subPath: project - - name: data - mountPath: /home/coder/.local/share/code-server - subPath: code-server + mountPath: /home/coder {{- range .Values.extraConfigmapMounts }} - name: {{ .name }} mountPath: {{ .mountPath }}