Skip to content

Commit

Permalink
Merge pull request #17804 from jakesmith/HPCC-30332-hostPath-volume-s…
Browse files Browse the repository at this point in the history
…upport

HPCC-30332 Add hostPath volume support

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Sep 22, 2023
2 parents ac97366 + 3b5c28e commit a4ec440
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
42 changes: 29 additions & 13 deletions helm/hpcc/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Add ConfigMap volume for a component

{{/*
Add volume mounts
Pass in root, me (the component), includeCategories (optional) and/or includeNames (optional)
Pass in root, me (the component), includeCategories (optional) and/or includeNames (optional), container identifier (optional)
Note: if there are multiple planes (other than dll, dali and spill planes), they should be all called with a single call
to addVolumeMounts so that if a plane can be used for multiple purposes then duplicate volume mounts are not created.
*/}}
Expand All @@ -339,6 +339,7 @@ to addVolumeMounts so that if a plane can be used for multiple purposes then dup
{{- $includeNames := .includeNames | default list -}}
{{- $component := .me -}}
{{- $previousMounts := dict -}}
{{- $id := .id | default "" -}}
{{- range $plane := $planes -}}
{{- if not $plane.disabled }}
{{- $componentMatches := or (not (hasKey $plane "components")) (has $component.name $plane.components) -}}
Expand All @@ -349,16 +350,24 @@ to addVolumeMounts so that if a plane can be used for multiple purposes then dup
{{- $mountPath := $plane.prefix }}
{{- $numMounts := int ( $plane.numMounts | default $plane.numDevices | default 1 ) }}
{{- if le $numMounts 1 }}
- name: {{ lower $plane.name }}-pv
- name: {{ lower $plane.name }}-volume
mountPath: {{ $mountPath | quote }}
{{- else }}
{{- range $elem := untilStep 1 (int (add $numMounts 1)) 1 }}
- name: {{ lower $plane.name }}-pv-many-{{ $elem }}
- name: {{ lower $plane.name }}-volume-many-{{ $elem }}
mountPath: {{ printf "%s/d%d" $mountPath $elem | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- $_ := set $previousMounts $plane.prefix true -}}
{{- else if $plane.hostPath }}
{{- if not (hasKey $previousMounts $plane.prefix) }}
- name: {{ lower $plane.name }}-volume
mountPath: {{ $plane.prefix | quote }}
{{- if $id }}
subPath: {{ printf "%s-%s" $component.name $id }}
{{- end }}
{{- end }}
{{- end }}

{{- /*Generate entries for each alias of the plane*/ -}}
Expand All @@ -370,11 +379,11 @@ to addVolumeMounts so that if a plane can be used for multiple purposes then dup
{{- $mountPath := $alias.prefix }}
{{- $numMounts := int ( $alias.numMounts | default $plane.numDevices | default 1 ) }}
{{- if le $numMounts 1 }}
- name: {{ lower $plane.name }}-pv-alias-{{ $curAlias.num }}
- name: {{ lower $plane.name }}-volume-alias-{{ $curAlias.num }}
mountPath: {{ $mountPath | quote }}
{{- else }}
{{- range $elem := untilStep 1 (int (add $numMounts 1)) 1 }}
- name: {{ lower $plane.name }}-pv-alias-{{ $curAlias.num }}-many-{{ $elem }}
- name: {{ lower $plane.name }}-volume-alias-{{ $curAlias.num }}-many-{{ $elem }}
mountPath: {{ printf "%s/d%d" $mountPath $elem | quote }}
{{- end }}
{{- end }}
Expand Down Expand Up @@ -411,18 +420,25 @@ The plane will generate a volume if it matches either an includeLabel or an incl
{{- $pvc := hasKey $plane "pvc" | ternary $plane.pvc (printf "%s-%s-pvc" (include "hpcc.fullname" $) $plane.name) }}
{{- $numMounts := int ( $plane.numMounts | default $plane.numDevices | default 1 ) }}
{{- if le $numMounts 1 }}
- name: {{ lower $plane.name }}-pv
- name: {{ lower $plane.name }}-volume
persistentVolumeClaim:
claimName: {{ $pvc }}
{{- else }}
{{- range $elem := until $numMounts }}
- name: {{ lower $plane.name }}-pv-many-{{ add $elem 1 }}
- name: {{ lower $plane.name }}-volume-many-{{ add $elem 1 }}
persistentVolumeClaim:
claimName: {{ $pvc }}-{{ add $elem 1 }}
{{- end }}
{{- end }}
{{- $_ := set $previousMounts $plane.prefix true }}
{{- end }}
{{- else if $plane.hostPath }}
{{- if not (hasKey $previousMounts $plane.prefix) }}
- name: {{ lower $plane.name }}-volume
hostPath:
path: {{ $plane.hostPath }}
type: Directory
{{- end }}
{{- end }}

{{- /*Generate entries for each alias of the plane*/ -}}
Expand All @@ -434,12 +450,12 @@ The plane will generate a volume if it matches either an includeLabel or an incl
{{- $pvc := $alias.pvc }}
{{- $numMounts := int ( $alias.numMounts | default $plane.numDevices | default 1 ) }}
{{- if le $numMounts 1 }}
- name: {{ lower $plane.name }}-pv-alias-{{ $curAlias.num }}
- name: {{ lower $plane.name }}-volume-alias-{{ $curAlias.num }}
persistentVolumeClaim:
claimName: {{ $pvc }}
{{- else }}
{{- range $elem := until $numMounts }}
- name: {{ lower $plane.name }}-pv-alias-{{ $curAlias.num }}-many-{{ add $elem 1 }}
- name: {{ lower $plane.name }}-volume-alias-{{ $curAlias.num }}-many-{{ add $elem 1 }}
persistentVolumeClaim:
claimName: {{ $pvc }}-{{ add $elem 1 }}
{{- end }}
Expand Down Expand Up @@ -897,19 +913,19 @@ NB: uid=10000 and gid=10001 are the uid/gid of the hpcc user, built into platfor
{{- $component := .me -}}
{{- range $plane := $planes -}}
{{- if not $plane.disabled -}}
{{- if (or ($plane.pvc) (hasKey $plane "storageClass")) -}}
{{- if (or ($plane.pvc) (or (hasKey $plane "storageClass") (hasKey $plane "hostPath"))) -}}
{{- $componentMatches := or (not (hasKey $plane "components")) (has $component.name $plane.components) -}}
{{- if and (or (has $plane.category $includeCategories) (has $plane.name $includeNames)) $componentMatches }}
{{- if $plane.forcePermissions -}}
{{- $planesToChown = append $planesToChown $plane -}}
{{- end -}}
{{- if $plane.waitForMount -}}
{{- $volumeName := (printf "%s-pv" $plane.name) -}}
{{- $volumeName := (printf "%s-volume" $plane.name) -}}
{{- include "hpcc.waitForMount" (dict "root" $root "me" $component "uid" $uid "gid" $gid "volumeName" $volumeName "volumePath" $plane.prefix) | nindent 0 }}
{{- end -}}
{{- if hasKey $plane "expert" -}}
{{- if $plane.expert.validatePlaneScript -}}
{{- $volumeName := (printf "%s-pv" $plane.name) -}}
{{- $volumeName := (printf "%s-volume" $plane.name) -}}
{{- include "hpcc.validatePlaneScript" (dict "root" $root "me" $component "uid" $uid "gid" $gid "volumeName" $volumeName "volumePath" $plane.prefix "cmds" $plane.expert.validatePlaneScript) | nindent 0 }}
{{- end -}}
{{- end -}}
Expand All @@ -920,7 +936,7 @@ NB: uid=10000 and gid=10001 are the uid/gid of the hpcc user, built into platfor
{{- $volumes := list -}}
{{- if len $planesToChown -}}
{{- range $plane := $planesToChown -}}
{{- $volumeName := (printf "%s-pv" $plane.name) -}}
{{- $volumeName := (printf "%s-volume" $plane.name) -}}
{{- $volumes = append $volumes (dict "name" $volumeName "path" $plane.prefix) -}}
{{- end -}}
{{- include "hpcc.changeMountPerms" (dict "root" $root "uid" $uid "gid" $gid "volumes" $volumes) | nindent 0 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/hpcc/templates/thor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ data:
workingDir: /var/lib/HPCCSystems
volumeMounts:
{{ include "hpcc.addConfigMapVolumeMount" $configCtx.me | indent 12 }}
{{ include "hpcc.addVolumeMounts" $configCtx | indent 12 }}
{{ include "hpcc.addVolumeMounts" (deepCopy $configCtx | merge (dict "id" (toString $containerNum))) | indent 12 }}
{{ include "hpcc.addSecretVolumeMounts" $configCtx | indent 12 }}
{{ include "hpcc.addCertificateVolumeMount" (dict "root" $configCtx.root "name" $configCtx.me.name "component" "thorworker") | indent 12 }}
{{- if and ($misc.postJobCommandViaSidecar) (eq $containerNum 1) }}
Expand Down
6 changes: 6 additions & 0 deletions helm/hpcc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@
"subPath": {},
"secret": {},
"pvc": {},
"hostPath": {},
"hostGroup": {},
"hosts": {},
"umask": {},
Expand Down Expand Up @@ -595,6 +596,10 @@
"description": "optional name of any secret required to access this storage plane",
"type": "string"
},
"hostPath": {
"description": "optional, this will create a hostPath volume (mutually exclusive with using pvc)",
"type": "string"
},
"pvc": {
"description": "optional name of the persistent volume claim for this plane",
"type": "string"
Expand Down Expand Up @@ -700,6 +705,7 @@
"subPath": {},
"secret": {},
"pvc": {},
"hostPath": {},
"hostGroup": {},
"hosts": {},
"umask": {},
Expand Down

0 comments on commit a4ec440

Please sign in to comment.