Skip to content

Commit 9cb1fd0

Browse files
authored
Merge pull request #1579 from porter-dev/main
move volume mounting improvements on porter charts to prod
2 parents 3acfbf3 + f63f0d2 commit 9cb1fd0

File tree

9 files changed

+136
-39
lines changed

9 files changed

+136
-39
lines changed

applications/job/form.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ tabs:
147147
label: Propagate SIGTERM to child processes.
148148
settings:
149149
default: true
150+
- name: persistence_toggle
151+
contents:
152+
- type: heading
153+
label: Persistent Disks
154+
- type: subtitle
155+
label: Attach persistent disks to your job to retain data across runs.
156+
- type: checkbox
157+
label: Enable Persistence
158+
variable: pvc.enabled
159+
- name: persistent_storage
160+
show_if: pvc.enabled
161+
contents:
162+
- type: number-input
163+
label: Persistent Storage
164+
variable: pvc.storage
165+
placeholder: "ex: 20"
166+
settings:
167+
unit: Gi
168+
default: 20
169+
- type: string-input
170+
label: Mount Path
171+
variable: pvc.mountPath
172+
placeholder: "ex: /mypath"
173+
settings:
174+
default: /mypath
150175
- type: heading
151176
label: Image Settings
152177
- type: subtitle

applications/job/templates/cronjob.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ spec:
175175
readOnly: true
176176
{{ end }}
177177
{{ end }}
178+
{{ if .Values.pvc.enabled }}
179+
volumeMounts:
180+
- name: "{{ include "docker-template.fullname" . }}-storage"
181+
mountPath: {{ .Values.pvc.mountPath }}
182+
{{ end }}
178183
resources:
179184
requests:
180185
cpu: {{ .Values.resources.requests.cpu }}
@@ -245,13 +250,22 @@ spec:
245250
mountPath: /secrets/
246251
readOnly: true
247252
{{ end }}
248-
{{ if or .Values.cloudsql.enabled .Values.fileSecretMounts.enabled}}
253+
{{ if or .Values.cloudsql.enabled .Values.fileSecretMounts.enabled .Values.pvc.enabled}}
249254
volumes:
250255
{{ if .Values.cloudsql.enabled }}
251256
- name: "sidecar-volume-{{ include "docker-template.fullname" . }}"
252257
secret:
253258
secretName: "{{ include "cloudsql.serviceAccountJSONSecret" . }}"
254259
{{ end }}
260+
{{ if .Values.pvc.enabled }}
261+
- name: "{{ include "docker-template.fullname" . }}-storage"
262+
persistentVolumeClaim:
263+
{{- if .Values.pvc.existingVolume }}
264+
claimName: {{ .Values.pvc.existingVolume }}
265+
{{- else }}
266+
claimName: "{{ include "docker-template.fullname" . }}-pvc"
267+
{{- end }}
268+
{{ end }}
255269
{{ if .Values.fileSecretMounts.enabled }}
256270
{{ range .Values.fileSecretMounts.mounts }}
257271
- name: {{ .mountPath }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if and .Values.pvc.enabled (not .Values.pvc.existingVolume) -}}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: "{{ include "docker-template.fullname" . }}-pvc"
6+
spec:
7+
accessModes:
8+
- ReadWriteOnce
9+
resources:
10+
requests:
11+
storage: {{ .Values.pvc.storage }}
12+
{{ end }}

applications/job/validate.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,28 @@
6868
}
6969
}
7070
}
71+
},
72+
"pvc": {
73+
"type": "object",
74+
"properties": {
75+
"enabled": {
76+
"type": "boolean",
77+
"default": false
78+
},
79+
"storage": {
80+
"type": "string",
81+
"pattern": "^\\d+(Ki|Mi|Gi|Ti)$",
82+
"default": "20Gi"
83+
},
84+
"mountPath": {
85+
"type": "string",
86+
"default": "/mypath"
87+
},
88+
"existingVolume": {
89+
"type": "string",
90+
"default": ""
91+
}
92+
}
7193
}
7294
}
7395
}

applications/job/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,11 @@ fileSecretMounts:
105105
# enable this conservatively
106106
enableHostIpc: false
107107

108+
pvc:
109+
enabled: false
110+
storage: 20Gi
111+
mountPath: /mypath
112+
existingVolume: ""
113+
108114
# job timeout configuration
109115
activeDeadlineSeconds: # Optional - if not set, will use sidecar.timeout

applications/web/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,16 @@ This helper uses the global .Values object.
173173
{{ $k }}: {{ $v | toString | trimPrefix "\"" | trimSuffix "\"" | quote }}
174174
{{- end }}
175175

176+
{{- end -}}
177+
178+
{{/*
179+
Return true if volumeMounts should be rendered in the main container
180+
181+
*/}}
182+
{{- define "web.shouldRenderVolumeMounts" -}}
183+
{{- if or .Values.datadogSocketVolume.enabled .Values.resources.requests.nvidiaGpu .Values.awsEfsStorage .Values.pvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) -}}
184+
true
185+
{{- else -}}
186+
false
187+
{{- end -}}
176188
{{- end -}}

applications/web/templates/deployment.yaml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -419,43 +419,40 @@ spec:
419419
- name: PORT
420420
value: {{ .Values.container.port | quote }}
421421
{{- end }}
422-
{{ if .Values.datadogSocketVolume.enabled }}
422+
{{- if include "web.shouldRenderVolumeMounts" . }}
423423
volumeMounts:
424+
{{- if .Values.datadogSocketVolume.enabled }}
424425
- name: datadog-apm-socket
425426
mountPath: /var/run/datadog/apm.socket
426427
- name: datadog-dsd-socket
427428
mountPath: /var/run/datadog/dsd.socket
428-
{{ end }}
429-
{{ if .Values.resources.requests.nvidiaGpu}}
430-
volumeMounts:
429+
{{ end }}
430+
{{- if .Values.resources.requests.nvidiaGpu}}
431431
- name: dshm
432432
mountPath: /dev/shm
433-
{{ end }}
434-
{{ if .Values.awsEfsStorage }}
435-
volumeMounts:
436-
{{- range $index, $v := .Values.awsEfsStorage }}
437-
- name: {{ include "docker-template.efsName" (dict "fullname" $.Values.fullnameOverride "index" $index) }}
438-
mountPath: {{ include "docker-template.efsMountPath" (dict "mountPath" $v.mountPath "fullname" $.Values.fullnameOverride) }}
439-
{{ end }}
440-
{{ end }}
441-
{{ if .Values.pvc.enabled }}
442-
volumeMounts:
433+
{{ end }}
434+
{{- if .Values.awsEfsStorage }}
435+
{{ range $index, $v := .Values.awsEfsStorage }}
436+
- name: {{ include "docker-template.efsName" (dict "fullname" $.Values.fullnameOverride "index" $index) }}
437+
mountPath: {{ include "docker-template.efsMountPath" (dict "mountPath" $v.mountPath "fullname" $.Values.fullnameOverride) }}
438+
{{ end }}
439+
{{ end }}
440+
{{- if .Values.pvc.enabled }}
443441
- name: "{{ include "docker-template.fullname" . }}-storage"
444442
mountPath: {{ .Values.pvc.mountPath }}
445443
{{ end }}
446-
{{ if .Values.emptyDir.enabled }}
447-
volumeMounts:
444+
{{- if .Values.emptyDir.enabled }}
448445
- name: "{{ include "docker-template.fullname" . }}-empty-dir-storage"
449446
mountPath: {{ .Values.emptyDir.mountPath }}
450447
{{ end }}
451-
{{ if and .Values.fileSecretMounts .Values.fileSecretMounts.enabled }}
448+
{{- if and .Values.fileSecretMounts .Values.fileSecretMounts.enabled }}
452449
{{ range .Values.fileSecretMounts.mounts }}
453-
volumeMounts:
454450
- name: {{ .mountPath }}
455451
mountPath: "/etc/secrets/{{ .mountPath }}"
456452
readOnly: true
457453
{{ end }}
458454
{{ end }}
455+
{{ end }}
459456
{{- if .Values.cloudsql.enabled }}
460457
- name: cloud-sql-proxy
461458
image: gcr.io/cloudsql-docker/gce-proxy:1.17

applications/worker/templates/_helpers.tpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,15 @@ For backwards compatibility, this concatenates targets from cloudsql.connectionN
9595
{{- end -}}
9696

9797
{{- end }}
98-
{{- end }}
98+
{{- end }}
99+
100+
{{/*
101+
Return true if volumeMounts should be rendered in the main container
102+
*/}}
103+
{{- define "worker.shouldRenderVolumeMounts" -}}
104+
{{- if or .Values.datadogSocketVolume.enabled .Values.pvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) .Values.additionalVolumes -}}
105+
true
106+
{{- else -}}
107+
false
108+
{{- end -}}
109+
{{- end -}}

applications/worker/templates/deployment.yaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -310,38 +310,36 @@ spec:
310310
{{- end }}
311311
{{- end }}
312312
{{- end }}
313-
{{ if .Values.datadogSocketVolume.enabled }}
313+
{{- if include "worker.shouldRenderVolumeMounts" . }}
314314
volumeMounts:
315+
{{- if .Values.datadogSocketVolume.enabled }}
315316
- name: datadog-apm-socket
316317
mountPath: /var/run/datadog/apm.socket
317318
- name: datadog-dsd-socket
318319
mountPath: /var/run/datadog/dsd.socket
319-
{{ end }}
320-
{{ if .Values.pvc.enabled }}
321-
volumeMounts:
320+
{{ end }}
321+
{{- if .Values.pvc.enabled }}
322322
- name: "{{ include "docker-template.fullname" . }}-storage"
323323
mountPath: {{ .Values.pvc.mountPath }}
324-
{{ end }}
325-
{{ if .Values.emptyDir.enabled }}
326-
volumeMounts:
324+
{{ end }}
325+
{{- if .Values.emptyDir.enabled }}
327326
- name: "{{ include "docker-template.fullname" . }}-empty-dir-storage"
328327
mountPath: {{ .Values.emptyDir.mountPath }}
329-
{{ end }}
330-
{{ if and .Values.fileSecretMounts .Values.fileSecretMounts.enabled }}
331-
{{ range .Values.fileSecretMounts.mounts }}
332-
volumeMounts:
328+
{{ end }}
329+
{{- if and .Values.fileSecretMounts .Values.fileSecretMounts.enabled }}
330+
{{ range .Values.fileSecretMounts.mounts }}
333331
- name: {{ .mountPath }}
334332
mountPath: "/etc/secrets/{{ .mountPath }}"
335333
readOnly: true
336-
{{ end }}
337-
{{ end }}
338-
{{ if .Values.additionalVolumes }}
339-
volumeMounts:
340-
{{- range .Values.additionalVolumes }}
334+
{{ end }}
335+
{{ end }}
336+
{{- if .Values.additionalVolumes }}
337+
{{ range .Values.additionalVolumes }}
341338
- name: {{ .name }}
342339
mountPath: {{ .mountPath }}
343-
{{- end }}
344-
{{ end }}
340+
{{ end }}
341+
{{ end }}
342+
{{ end }}
345343
{{- if .Values.cloudsql.enabled }}
346344
- name: cloud-sql-proxy
347345
image: gcr.io/cloudsql-docker/gce-proxy:1.17
@@ -438,7 +436,7 @@ spec:
438436
{{ if .Values.emptyDir.enabled }}
439437
- name: "{{ include "docker-template.fullname" . }}-empty-dir-storage"
440438
emptyDir:
441-
{{- toYaml .Values.emptyDir.volumeOptions | nindent 8 }}
439+
{{- toYaml .Values.emptyDir.volumeOptions | nindent 12}}
442440
{{ end }}
443441
{{ if .Values.fileSecretMounts.enabled }}
444442
{{ range .Values.fileSecretMounts.mounts }}

0 commit comments

Comments
 (0)