Skip to content

Commit fb18c9f

Browse files
authored
Merge pull request #1608 from porter-dev/ym/host_volume_mounts_porter_apps
feat: add a host volumes options to porter apps
2 parents f540216 + f163c2d commit fb18c9f

File tree

9 files changed

+87
-11
lines changed

9 files changed

+87
-11
lines changed

applications/job/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Return true if volumeMounts should be rendered in the main container
109109
110110
*/}}
111111
{{- define "job.shouldRenderVolumeMounts" -}}
112-
{{- if or .Values.pvc.enabled .Values.multiplePvc.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) -}}
112+
{{- if or .Values.pvc.enabled .Values.multiplePvc.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) .Values.hostVolumeMounts -}}
113113
true
114114
{{- else -}}
115115
false

applications/job/templates/cronjob.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,18 @@ spec:
181181
- name: "{{ include "docker-template.fullname" . }}-storage"
182182
mountPath: {{ .Values.pvc.mountPath }}
183183
{{ end }}
184+
{{ if .Values.hostVolumeMounts }}
185+
{{ range .Values.hostVolumeMounts }}
186+
- name: {{ .name }}
187+
mountPath: {{ .mountPath }}
188+
{{ end }}
189+
{{ end }}
184190
{{- if .Values.multiplePvc.enabled }}
185191
{{- range .Values.multiplePvc.volumes }}
186-
- name: {{ .name }}
187-
mountPath: {{ .mountPath }}
188-
{{- end }}
189-
{{- end }}
192+
- name: {{ .name }}
193+
mountPath: {{ .mountPath }}
194+
{{ end }}
195+
{{ end }}
190196
resources:
191197
requests:
192198
cpu: {{ .Values.resources.requests.cpu }}
@@ -257,7 +263,7 @@ spec:
257263
mountPath: /secrets/
258264
readOnly: true
259265
{{ end }}
260-
{{ if or .Values.cloudsql.enabled .Values.fileSecretMounts.enabled .Values.pvc.enabled .Values.multiplePvc.enabled }}
266+
{{ if or .Values.cloudsql.enabled .Values.fileSecretMounts.enabled .Values.pvc.enabled .Values.multiplePvc.enabled .Values.hostVolumeMounts }}
261267
volumes:
262268
{{ if .Values.cloudsql.enabled }}
263269
- name: "cloud-sql-proxy-service-account-secret"
@@ -287,6 +293,12 @@ spec:
287293
secretName: "{{ .secretName }}"
288294
{{ end }}
289295
{{ end }}
296+
{{ range .Values.hostVolumeMounts }}
297+
- name: {{ .name }}
298+
hostPath:
299+
path: {{ .hostPath }}
300+
type: {{ .type | default "DirectoryOrCreate" }}
301+
{{ end }}
290302
{{ end }}
291303
restartPolicy: Never
292304
shareProcessNamespace: true

applications/job/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ fileSecretMounts:
100100
enabled: false
101101
mounts: []
102102

103+
# Host volume mounts for mounting host directories into containers
104+
# Format: hostVolumeMounts: [{name: <NAME>, hostPath: <HOST_PATH>, mountPath: <CONTAINER_PATH>, type: <HOSTPATH_TYPE>},..]
105+
hostVolumeMounts: []
106+
# Example:
107+
# hostVolumeMounts:
108+
# - name: nvme-storage
109+
# hostPath: /mnt/nvme-shared
110+
# mountPath: /tmp/nvme
111+
# type: DirectoryOrCreate
112+
# - name: docker-socket
113+
# hostPath: /var/run/docker.sock
114+
# mountPath: /var/run/docker.sock
115+
# type: Socket
116+
103117
# hostIPC is required on pods that need to access the host's IPC namespace
104118
# this is the case for instance for pods that need to use the MPS sliced GPUs
105119
# enable this conservatively

applications/web/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Return true if volumeMounts should be rendered in the main container
180180
181181
*/}}
182182
{{- define "web.shouldRenderVolumeMounts" -}}
183-
{{- if or .Values.datadogSocketVolume.enabled .Values.resources.requests.nvidiaGpu .Values.awsEfsStorage .Values.pvc.enabled .Values.multiplePvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) -}}
183+
{{- if or .Values.datadogSocketVolume.enabled .Values.resources.requests.nvidiaGpu .Values.awsEfsStorage .Values.pvc.enabled .Values.multiplePvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) .Values.hostVolumeMounts -}}
184184
true
185185
{{- else -}}
186186
false

applications/web/templates/deployment.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ spec:
8282
requiredDuringSchedulingIgnoredDuringExecution:
8383
nodeSelectorTerms:
8484
- matchExpressions:
85+
{{- if .Values.nodeGroups }}
8586
- key: porter.run/node-group-id
8687
operator: In
8788
values:
8889
{{- range $nodeGroup := .Values.nodeGroups }}
8990
- {{ $nodeGroup.id | quote }}
9091
{{- end }}
92+
{{- end }}
9193
{{- end }}
9294
serviceAccountName: {{ include "docker-template.serviceAccountName" . }}
9395
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
@@ -459,6 +461,10 @@ spec:
459461
readOnly: true
460462
{{ end }}
461463
{{ end }}
464+
{{- range .Values.hostVolumeMounts }}
465+
- name: {{ .name }}
466+
mountPath: {{ .mountPath }}
467+
{{- end }}
462468
{{ end }}
463469
{{- if .Values.cloudsql.enabled }}
464470
- name: cloud-sql-proxy
@@ -527,7 +533,7 @@ spec:
527533
{{- end }}
528534
{{- end }}
529535
{{ end }}
530-
{{ if or .Values.pvc.enabled .Values.multiplePvc.enabled .Values.resources.requests.nvidiaGpu .Values.cloudsql.enabled .Values.emptyDir.enabled .Values.fileSecretMounts.enabled .Values.awsEfsStorage .Values.datadogSocketVolume.enabled }}
536+
{{ if or .Values.pvc.enabled .Values.multiplePvc.enabled .Values.resources.requests.nvidiaGpu .Values.cloudsql.enabled .Values.emptyDir.enabled .Values.fileSecretMounts.enabled .Values.awsEfsStorage .Values.datadogSocketVolume.enabled .Values.hostVolumeMounts }}
531537
volumes:
532538
{{ if .Values.datadogSocketVolume.enabled }}
533539
- hostPath:
@@ -585,5 +591,11 @@ spec:
585591
secretName: "{{ .secretName }}"
586592
{{ end }}
587593
{{ end }}
594+
{{ range .Values.hostVolumeMounts }}
595+
- name: {{ .name }}
596+
hostPath:
597+
path: {{ .hostPath }}
598+
type: {{ .type | default "DirectoryOrCreate" }}
599+
{{- end }}
588600
{{ end }}
589601
{{- end }}

applications/web/values.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,18 @@ deploymentStrategy:
336336
maxSurge: 25%
337337
maxUnavailable: 25%
338338
# blueGreen:
339-
# group: ""
339+
# group: ""
340+
341+
# Host volume mounts for mounting host directories into containers
342+
# Format: hostVolumeMounts: [{name: <NAME>, hostPath: <HOST_PATH>, mountPath: <CONTAINER_PATH>, type: <HOSTPATH_TYPE>},..]
343+
hostVolumeMounts: []
344+
# Example:
345+
# hostVolumeMounts:
346+
# - name: nvme-storage
347+
# hostPath: /mnt/nvme-shared
348+
# mountPath: /tmp/nvme
349+
# type: DirectoryOrCreate
350+
# - name: docker-socket
351+
# hostPath: /var/run/docker.sock
352+
# mountPath: /var/run/docker.sock
353+
# type: Socket

applications/worker/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ For backwards compatibility, this concatenates targets from cloudsql.connectionN
101101
Return true if volumeMounts should be rendered in the main container
102102
*/}}
103103
{{- define "worker.shouldRenderVolumeMounts" -}}
104-
{{- if or .Values.datadogSocketVolume.enabled .Values.pvc.enabled .Values.multiplePvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) .Values.additionalVolumes -}}
104+
{{- if or .Values.datadogSocketVolume.enabled .Values.pvc.enabled .Values.multiplePvc.enabled .Values.emptyDir.enabled (and .Values.fileSecretMounts .Values.fileSecretMounts.enabled) .Values.hostVolumeMounts .Values.additionalVolumes -}}
105105
true
106106
{{- else -}}
107107
false

applications/worker/templates/deployment.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ spec:
346346
mountPath: {{ .mountPath }}
347347
{{ end }}
348348
{{ end }}
349+
{{ range .Values.hostVolumeMounts }}
350+
- name: {{ .name }}
351+
mountPath: {{ .mountPath }}
352+
{{- end }}
349353
{{ end }}
350354
{{- if .Values.cloudsql.enabled }}
351355
- name: cloud-sql-proxy
@@ -414,7 +418,7 @@ spec:
414418
{{- end }}
415419
{{- end }}
416420
{{ end }}
417-
{{ if or .Values.pvc.enabled .Values.multiplePvc.enabled .Values.cloudsql.enabled .Values.emptyDir.enabled .Values.datadogSocketVolume.enabled .Values.fileSecretMounts.enabled (and .Values.additionalVolumes (not (empty .Values.additionalVolumes))) }}
421+
{{ if or .Values.pvc.enabled .Values.multiplePvc.enabled .Values.cloudsql.enabled .Values.emptyDir.enabled .Values.datadogSocketVolume.enabled .Values.fileSecretMounts.enabled .Values.hostVolumeMounts (and .Values.additionalVolumes (not (empty .Values.additionalVolumes))) }}
418422
volumes:
419423
{{ if .Values.datadogSocketVolume.enabled }}
420424
- hostPath:
@@ -466,4 +470,10 @@ spec:
466470
{{- toYaml .volumeOptions | nindent 12 }}
467471
{{- end }}
468472
{{ end }}
473+
{{- range .Values.hostVolumeMounts }}
474+
- name: {{ .name }}
475+
hostPath:
476+
path: {{ .hostPath }}
477+
type: {{ .type | default "DirectoryOrCreate" }}
478+
{{- end }}
469479
{{ end }}

applications/worker/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ fileSecretMounts:
194194
enabled: false
195195
mounts: []
196196

197+
# Host volume mounts for mounting host directories into containers
198+
# Format: hostVolumeMounts: [{name: <NAME>, hostPath: <HOST_PATH>, mountPath: <CONTAINER_PATH>, type: <HOSTPATH_TYPE>},..]
199+
hostVolumeMounts: []
200+
# Example:
201+
# hostVolumeMounts:
202+
# - name: nvme-storage
203+
# hostPath: /mnt/nvme-shared
204+
# mountPath: /tmp/nvme
205+
# type: DirectoryOrCreate
206+
# - name: docker-socket
207+
# hostPath: /var/run/docker.sock
208+
# mountPath: /var/run/docker.sock
209+
# type: Socket
210+
197211
# set this to add additional volumes to the deployment
198212
additionalVolumes:
199213
# - name: ""

0 commit comments

Comments
 (0)