瀏覽代碼

Merge pull request #14987 from ghalliday/issue25952

HPCC-25952 Allow planes to create implicit persistent volume claims

Reviewed-By: Jake Smith <jake.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 4 年之前
父節點
當前提交
a3cf06574d

+ 143 - 48
helm/hpcc/templates/_helpers.tpl

@@ -68,19 +68,49 @@ Translate a port list to a comma-separated list
  {{- end -}}
 {{- end -}}
 
+{{- define "hpcc.getFirstPlaneForLabel" -}}
+{{- $root := .root -}}
+{{- $label := .label -}}
+{{- $storage := ($root.Values.storage | default dict) -}}
+{{- $planes := ($storage.planes | default list) -}}
+{{- $firstPlane := dict -}}
+{{- range $plane := $planes -}}
+{{- if not $firstPlane.plane -}}
+{{- $labels := $plane.labels | default (list "data") -}}
+{{- if (has $label $labels) -}}
+{{- $_ := set $firstPlane "plane" $plane.name -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- if $firstPlane.plane -}}
+{{- $firstPlane.plane -}}
+{{- end -}}
+{{- end -}}
+
+{{- define "hpcc.hasPlaneForLabel" -}}
+{{- if (include "hpcc.getFirstPlaneForLabel" .) -}}
+true
+{{- end -}}
+{{- end -}}
+
 {{/*
 Get default data plane
 */}}
 {{- define "hpcc.getDefaultDataPlane" -}}
 {{- $storage := ($.Values.storage | default dict) -}}
-{{- $planes := ($storage.planes | default list) -}}
-{{- $firstPlane := dict -}}
-{{- range $plane := $planes -}}
- {{- if and (not $firstPlane.plane) (or (not $plane.labels) (has "data" $plane.labels)) }}
- {{- $_ := set $firstPlane "plane" $plane.name -}}
- {{- end -}}
+{{- $dataStorage := ($storage.dataStorage | default dict) -}}
+{{- $firstPlane := (include "hpcc.getFirstPlaneForLabel" (dict "root" $ "label" "data")) -}}
+{{- $dataStorage.plane | default $firstPlane | default "hpcc-data-plane" -}}
 {{- end -}}
-{{- printf "%s" ($storage.dataStorage.plane | default $firstPlane.plane | default "hpcc-data-plane") -}}
+
+{{/*
+Get default dll plane
+*/}}
+{{- define "hpcc.getDefaultDllPlane" -}}
+{{- $storage := ($.Values.storage | default dict) -}}
+{{- $dllStorage := ($storage.dllStorage | default dict) -}}
+{{- $firstPlane := (include "hpcc.getFirstPlaneForLabel" (dict "root" $ "label" "dll")) -}}
+{{- $dllStorage.plane | default $firstPlane | default "hpcc-dll-plane" -}}
 {{- end -}}
 
 {{/*
@@ -121,20 +151,24 @@ storage:
     labels:
     - data
   {{- end }}
-{{ toYaml (unset (unset (deepCopy $plane) "name") "pvc")| indent 4 }}
+{{ toYaml (omit $plane "name" "pvc" "storageClass" "storageSize") | indent 4 }}
  {{- end }}
 {{- end }}
 {{- /* Add implicit planes if data or spill storage plane not specified*/ -}}
 {{- if not $dataStorage.plane }}
+{{- if not (include "hpcc.hasPlaneForLabel" (dict "root" $ "label" "data")) }}
   - name: hpcc-data-plane
     labels:
     - data
     prefix: {{ .Values.global.defaultDataPath | default "/var/lib/HPCCSystems/hpcc-data" | quote }}
 {{- end }}
+{{- end }}
 {{- if not $spillStorage.plane }}
+{{- if not (include "hpcc.hasPlaneForLabel" (dict "root" $ "label" "spill")) }}
   - name: hpcc-spill-plane
     prefix: {{ .Values.global.defaultSpillPath | default "/var/lib/HPCCSystems/hpcc-spill" | quote }}
 {{- end }}
+{{- end }}
 {{- if .Values.global.cost }}
 cost:
 {{ toYaml .Values.global.cost | indent 2 }}
@@ -229,21 +263,21 @@ to addVolumeMounts so that if a plane can be used for multiple purposes then dup
 {{- define "hpcc.addVolumeMounts" -}}
 {{- /*Create local variables which always exist to avoid having to check if intermediate key values exist*/ -}}
 {{- $storage := (.root.Values.storage | default dict) -}}
-{{- $dataStorage := ($storage.dataStorage | default dict) -}}
 {{- $planes := ($storage.planes | default list) -}}
 {{- $includeLabels := .includeLabels | default list -}}
 {{- range $plane := $planes -}}
- {{- if $plane.pvc -}}
-  {{- $matchedLabels := include "hpcc.doesStorageLabelsMatch" (dict "plane" $plane "includeLabels" $includeLabels) -}}
-  {{- if ne $matchedLabels "" }}
+ {{- if or ($plane.pvc) (hasKey $plane "storageClass") -}}
+  {{- $mountpath := $plane.prefix -}}
+  {{- $matchedLabels := include "hpcc.doesStorageLabelsMatch" (dict "plane" $plane "includeLabels" $includeLabels) }}
+  {{ if ne $matchedLabels "" }}
    {{- $num := int ( $plane.numDevices | default 1 ) -}}
    {{- if le $num 1 }}
 - name: {{ lower $plane.name }}-pv
-  mountPath: {{ $plane.prefix | quote }}
+  mountPath: {{ $mountpath | quote }}
    {{- else }}
     {{- range $elem := untilStep 1 (int (add $num 1)) 1 }}
 - name: {{ lower $plane.name }}-pv-many-{{- $elem }}
-  mountPath: {{ printf "%s/d%d" $plane.prefix $elem | quote }}
+  mountPath: {{ printf "%s/d%d" $mountpath $elem | quote }}
     {{- end }}
    {{- end }}
   {{- end }}
@@ -254,10 +288,13 @@ Create a data volume mount if data plane have not been specified in storage.plan
 Note: Some services used addVolumeMounts to add data planes and other types of plane using addVolumeMounts, so this code has
 to be located here rather than in addDataVolumeMount.
 */ -}}
+{{- $dataStorage := ($storage.dataStorage | default dict) -}}
 {{- if and (has "data" $includeLabels) (not $dataStorage.plane) }}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" .root "label" "data"))) }}
 - name: datastorage
   mountPath: "/var/lib/HPCCSystems/hpcc-data"
 {{- end }}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -265,7 +302,7 @@ Add data volume mount
 Pass in root
 */}}
 {{- define "hpcc.addDataVolumeMount" -}}
-{{- include "hpcc.addVolumeMounts" (dict "root" .root "includeLabels" (list "data" "")) -}}
+{{- include "hpcc.addVolumeMounts" (dict "root" .root "includeLabels" (list "data" "" "lz")) -}}
 {{- end -}}
 
 {{/*
@@ -278,22 +315,25 @@ Pass in root and includeLabels (optional)
 {{- $dataStorage := ($storage.dataStorage | default dict) -}}
 {{- $planes := ($storage.planes | default list) -}}
 {{- $includeLabels := .includeLabels | default list -}}
+{{- $filterName := .name | default "" -}}
 {{- range $plane := $planes -}}
- {{- if $plane.pvc -}}
+ {{- if or ($plane.pvc) (hasKey $plane "storageClass") -}}
   {{- $matchedLabels := include "hpcc.doesStorageLabelsMatch" (dict "plane" $plane "includeLabels" $includeLabels) -}}
   {{- if ne $matchedLabels "" }}
-   {{- $num := int ( $plane.numDevices | default 1 ) -}}
-   {{- $pvc := $plane.pvc | required (printf "pvc for %s not supplied" $plane.name) }}
-   {{- if le $num 1 }}
+   {{- if or (not $filterName) (eq $filterName $plane.name) }}
+    {{- $pvc := hasKey $plane "pvc" | ternary $plane.pvc (printf "%s-%s-pvc" (include "hpcc.fullname" $) $plane.name) -}}
+    {{- $num := int ( $plane.numDevices | default 1 ) -}}
+    {{- if le $num 1 }}
 - name: {{ lower $plane.name }}-pv
   persistentVolumeClaim:
     claimName: {{ $pvc }}
-   {{- else }}
-    {{- range $elem := until $num }}
+    {{- else }}
+     {{- range $elem := until $num }}
 - name: {{ lower $plane.name }}-pv-many-{{- add $elem 1 }}
   persistentVolumeClaim:
     claimName: {{ $pvc }}-{{- add $elem 1 }}
-    {{- end }}
+     {{- end }}
+    {{- end -}}
    {{- end -}}
   {{- end }}
  {{- end }}
@@ -304,10 +344,12 @@ Note: Some services used addVolumes to add data planes and other types of plane
 to be located here rather than in addDataVolumes.
 */ -}}
 {{- if and (has "data" $includeLabels) (not $dataStorage.plane) }}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" .root "label" "data"))) }}
 - name: datastorage
   persistentVolumeClaim:
     claimName: {{ $dataStorage.existingClaim | default (printf "%s-datastorage" (include "hpcc.fullname" . )) }}
 {{- end }}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -315,7 +357,7 @@ Add data volume
 Pass in dict with root
 */}}
 {{- define "hpcc.addDataVolume" -}}
-{{- include "hpcc.addVolumes" (dict "root" .root "includeLabels" (list "data" "") ) -}}
+{{- include "hpcc.addVolumes" (dict "root" .root "includeLabels" (list "data" "" "lz") ) -}}
 {{- end -}}
 
 {{/*
@@ -328,7 +370,7 @@ Pass in dict with root, me, name, and optional path
 {{- if .me.plane -}}
 {{- $me := .me -}}
  {{- range $plane := $planes -}}
-  {{- if and ($plane.pvc) (eq $plane.name $me.plane) -}}
+  {{- if and (or ($plane.pvc) (hasKey $plane "storageClass")) (eq $plane.name $me.plane) -}}
 {{ $plane.prefix }}
   {{- end -}}
  {{- end -}}
@@ -344,7 +386,7 @@ Pass in dict with root, me, name, and optional path
 {{- define "hpcc.addVolumeMount" -}}
 {{- $mountPath := include "hpcc.getVolumeMountPrefix" . }}
 {{- if not $mountPath -}}
-{{- $_ := fail (printf "Invalid storage definition for:" .name ) -}}
+{{- $_ := fail (printf "Invalid storage definition for: %s" .name ) -}}
 {{- end -}}
 - name: {{ .name }}
   mountPath: {{ $mountPath }}
@@ -358,8 +400,13 @@ Pass in dict with root
 {{- $storage := (.root.Values.storage | default dict) -}}
 {{- $planes := ($storage.planes | default list) -}}
 {{- $dllStorage := ($storage.dllStorage | default dict) -}}
+{{- if not $dllStorage.plane -}}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" .root "label" "dll"))) }}
 {{ include "hpcc.addVolumeMount" (dict "root" .root "me" $dllStorage "name" ($dllStorage.plane | default "dllstorage") "path" "queries") }}
 {{- end -}}
+{{- end -}}
+{{- include "hpcc.addVolumeMounts" (dict "root" .root "includeLabels" (list "dll")) -}}
+{{- end -}}
 
 {{/*
 Add dali volume mount - if default plane is used, or the dali storage plane specifies a pvc
@@ -369,8 +416,13 @@ Pass in dict with root
 {{- $storage := (.root.Values.storage | default dict) -}}
 {{- $planes := ($storage.planes | default list) -}}
 {{- $daliStorage := ($storage.daliStorage | default dict) -}}
+{{- if not $daliStorage.plane -}}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" .root "label" "dali"))) }}
 {{ include "hpcc.addVolumeMount" (dict "root" .root "me" $daliStorage "name" ($daliStorage.plane | default "dalistorage") "path" "dalistorage") }}
 {{- end -}}
+{{- end -}}
+{{- include "hpcc.addVolumeMounts" (dict "root" .root "includeLabels" (list "dali")) -}}
+{{- end -}}
 
 {{/*
 Add a volume - if default plane is used, or the storage plane specifies a pvc
@@ -380,19 +432,13 @@ Pass in dict with root, me and name
 {{- /*Create local variables which always exist to avoid having to check if intermediate key values exist*/ -}}
 {{- $storage := (.root.Values.storage | default dict) -}}
 {{- $planes := ($storage.planes | default list) -}}
-{{- if .me.plane -}}
-{{- $me := .me -}}
- {{- range $plane := $planes -}}
-  {{- if and ($plane.pvc) (eq $plane.name $me.plane) -}}
-- name: {{ .name }}
-  persistentVolumeClaim:
-    claimName: {{ $plane.pvc }}
-  {{- end }}
- {{- end }}
-{{- else -}}
+{{- $label := .label -}}
+{{- if not .me.plane -}}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" .root "label" $label))) }}
 - name: {{ .name }}
   persistentVolumeClaim:
     claimName: {{ .me.existingClaim | default (printf "%s-%s" (include "hpcc.fullname" .) .name) }}
+{{- end }}
 {{- end -}}
 {{- end -}}
 
@@ -404,7 +450,8 @@ Pass in dict with root
 {{- /*Create local variables which always exist to avoid having to check if intermediate key values exist*/ -}}
 {{- $storage := (.root.Values.storage | default dict) -}}
 {{- $dllStorage := ($storage.dllStorage | default dict) -}}
-{{ include "hpcc.addVolume" (dict "root" .root "name" "dllstorage" "me" $dllStorage) }}
+{{- include "hpcc.addVolume" (dict "root" .root "name" "dllstorage" "me" $dllStorage "label" "dll") }}
+{{- include "hpcc.addVolumes" (dict "root" .root "includeLabels" (list "dll") ) }}
 {{- end -}}
 
 {{/*
@@ -415,7 +462,8 @@ Pass in dict with root
 {{- /*Create local variables which always exist to avoid having to check if intermediate key values exist*/ -}}
 {{- $storage := (.root.Values.storage | default dict) -}}
 {{- $daliStorage := ($storage.daliStorage | default dict) -}}
-{{ include "hpcc.addVolume" (dict "root" .root "name" "dalistorage" "me" $daliStorage) }}
+{{- include "hpcc.addVolume" (dict "root" .root "name" "dalistorage" "me" $daliStorage "label" "dali") }}
+{{- include "hpcc.addVolumes" (dict "root" .root "includeLabels" (list "dali") ) }}
 {{- end -}}
 
 {{/*
@@ -591,6 +639,26 @@ A kludge to ensure mounted storage (e.g. for nfs, minikube or docker for desktop
 {{- end }}
 
 {{/*
+A kludge to ensure mounted storage (e.g. for nfs, minikube or docker for desktop) has correct permissions for PV
+*/}}
+{{- define "hpcc.changePlaneMountPerms" -}}
+{{- $storage := (.root.Values.storage | default dict) -}}
+{{- $planes := ($storage.planes | default list) -}}
+  {{- $includeLabels := .includeLabels | default list -}}
+{{- range $plane := $planes -}}
+ {{- if and ($plane.forcePermissions) (or ($plane.pvc) (hasKey $plane "storageClass")) -}}
+  {{- $mountpath := $plane.prefix -}}
+  {{- $matchedLabels := include "hpcc.doesStorageLabelsMatch" (dict "plane" $plane "includeLabels" $includeLabels) }}
+  {{- if ne $matchedLabels "" }}
+{{- $volumeName := (printf "%s-pv" $plane.name) -}}
+{{ include "hpcc.changeMountPerms" (dict "root" .root "volumeName" $volumeName "volumePath" $plane.prefix) }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+
+{{/*
 Container to watch for a file on a shared mount and execute a command
 Pass in dict with me and command
 NB: an alternative to sleep loop would be to install and make use of inotifywait
@@ -639,11 +707,14 @@ Add wait-and-run shared inter container volume
 Check dll mount point, using hpcc.changeMountPerms
 */}}
 {{- define "hpcc.checkDllMount" -}}
-{{- if .root.Values.storage.dllStorage.forcePermissions | default false }}
-{{- $volumeName := (.root.Values.storage.dllStorage.plane | default "dll") -}}
-{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" .root.Values.storage.dllStorage "name" "dll" "path" "queries") }}
+{{- $storage := (.root.Values.storage | default dict) -}}
+{{- $dllStorage := ($storage.dllStorage | default dict) -}}
+{{- if $dllStorage.forcePermissions | default false }}
+{{- $volumeName := ($dllStorage.plane | ternary (printf "%s-pv" $dllStorage.plane) "dll") -}}
+{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" $dllStorage "name" "dll" "path" "queries") }}
 {{ include "hpcc.changeMountPerms" (dict "root" .root "volumeName" $volumeName "volumePath" $volumePath) }}
 {{- end }}
+{{ include "hpcc.changePlaneMountPerms" (dict "root" .root "includeLabels" (list "dll")) }}
 {{- end }}
 
 {{/*
@@ -651,22 +722,28 @@ Check datastorage mount point, using hpcc.changeMountPerms
 Pass in a dictionary with root
 */}}
 {{- define "hpcc.checkDataMount" -}}
-{{- if .root.Values.storage.dataStorage.forcePermissions | default false }}
-{{- $volumeName := printf "%s-pv" .root.Values.storage.dataStorage.plane -}}
-{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" .root.Values.storage.dataStorage "name" "data" "path" "hpcc-data") }}
+{{- $storage := (.root.Values.storage | default dict) -}}
+{{- $dataStorage := ($storage.dataStorage | default dict) -}}
+{{- if $dataStorage.forcePermissions | default false }}
+{{- $volumeName := printf "%s-pv" $dataStorage.plane -}}
+{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" $dataStorage "name" "data" "path" "hpcc-data") }}
 {{ include "hpcc.changeMountPerms" (dict "root" .root "volumeName" $volumeName "volumePath" $volumePath) }}
 {{- end }}
+{{ include "hpcc.changePlaneMountPerms" (dict "root" .root "includeLabels" (list "" "data" "lz")) }}
 {{- end }}
 
 {{/*
 Check dalistorage mount point, using hpcc.changeMountPerms
 */}}
 {{- define "hpcc.checkDaliMount" -}}
-{{- if .root.Values.storage.daliStorage.forcePermissions | default false }}
-{{- $volumeName := (.root.Values.storage.daliStorage.plane | default "dalistorage") -}}
-{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" .root.Values.storage.daliStorage "name" "dali" "path" "dalistorage") }}
+{{- $storage := (.root.Values.storage | default dict) -}}
+{{- $daliStorage := ($storage.daliStorage | default dict) -}}
+{{- if $daliStorage.forcePermissions | default false }}
+{{- $volumeName := ($daliStorage.plane | default "dalistorage") -}}
+{{- $volumePath :=  include "hpcc.getVolumeMountPrefix" (dict "root" .root "me" $daliStorage "name" "dali" "path" "dalistorage") }}
 {{ include "hpcc.changeMountPerms" (dict "root" .root "volumeName" $volumeName "volumePath" $volumePath) }}
 {{- end }}
+{{ include "hpcc.changePlaneMountPerms" (dict "root" .root "includeLabels" (list "dali")) }}
 {{- end }}
 
 {{/*
@@ -928,7 +1005,8 @@ Pass in dict with root and me
 {{- define "hpcc.addSashaVolumes" }}
 {{- $serviceName := printf "sasha-%s" .me.name -}}
 {{- if .me.storage }}
-{{ include "hpcc.addVolume" (dict "root" .root "name" $serviceName "me" .me.storage) -}}
+{{ include "hpcc.addVolume" (dict "root" .root "name" $serviceName "me" .me.storage "label" "sasha") -}}
+{{ include "hpcc.addVolumes" (dict "root" .root "includeLabels" (list "sasha") "name" .me.storage.plane ) }}
 {{- end }}
 {{ with (dict "name" $serviceName) -}}
 {{ include "hpcc.addConfigMapVolume" . }}
@@ -1011,6 +1089,22 @@ spec:
   storageClassName: "{{ .me.storageClass }}"
 {{- end }}
 {{- end }}
+---
+{{- end -}}
+
+{{/*
+A template to generate PVCs for each storage plane that has storageSize defined and has the appropriate label
+Pass in dict with root, label.  optional name to restrict it to a single name.
+*/}}
+{{- define "hpcc.addPVCsFromPlanes" }}
+{{- $storage := (.Values.storage | default dict) }}
+{{- $planes := ($storage.planes | default list) -}}
+{{- range $plane := $planes -}}
+{{- if (hasKey $plane "storageClass") }}
+{{- $pvcname := (printf "%s-pvc" $plane.name) -}}
+{{- include "hpcc.addPVC" (dict "root" $ "name" $pvcname "me" $plane) }}
+{{- end }}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -1023,7 +1117,8 @@ Pass in dict with placement
 {{- end -}}
 {{- end -}}
 
-{{/*                                                                                                                            Check if there is any placement configuration
+{{/*
+Check if there is any placement configuration
 Pass in dict with root, job, target and type
 */}}
 {{- define "hpcc.placementsByJobTargetType" -}}

+ 0 - 7
helm/hpcc/templates/dali.yaml

@@ -173,12 +173,5 @@ spec:
 ---
 {{ include "hpcc.addCertificate" (dict "root" $ "name" .name "service" . "component" "dali" "external" false) }}
 
-{{- $storage := ($.Values.storage | default dict) -}}
-{{- $daliStorage := ($storage.daliStorage | default dict) -}}
-{{- if (and (not $daliStorage.existingClaim) (not $daliStorage.plane)) }}
-{{- $services := (.services | default dict) -}}
-{{- $modeForCoalescer := (hasKey $services "coalescer") | ternary "ReadWriteOnce" "ReadWriteMany" -}}
-{{- include "hpcc.addPVC" (dict "root" $ "name" "dalistorage" "mode" $modeForCoalescer "me" $daliStorage) -}}
-{{- end }}
 {{- end }}
 {{- end }}

+ 0 - 28
helm/hpcc/templates/dllserver-pvc.yaml

@@ -1,28 +0,0 @@
-{{/*
-
----  DO NOT EDIT THIS FILE - all configuration of HPCC platform should be done via values.yaml ----
-  
-##############################################################################
-
-    HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-    
-##############################################################################
-
-*/}}
-{{- $storage := (.Values.storage | default dict) -}}
-{{- $dllStorage := ($storage.dllStorage | default dict) -}}
-{{- if (and (not $dllStorage.existingClaim) (not $dllStorage.plane)) }}
-{{ include "hpcc.addPVC" (dict "root" $ "name" "dllstorage" "me" $dllStorage) }}
-{{- end }}

+ 1 - 0
helm/hpcc/templates/sasha.yaml

@@ -76,6 +76,7 @@ kind: ConfigMap
 {{- if and (not $sasha.storage.existingClaim) (not $sasha.storage.plane) }}
 {{ include "hpcc.addPVC" (dict "root" $ "name" (printf "sasha-%s" $sasha.name) "me" $sasha.storage) }}
 {{- end }}
+{{/* Any PVCS for sasha that are based on planes have already been generated in dali.yaml */}}
 ---
 {{ end -}}
 {{- end }}

+ 19 - 2
helm/hpcc/templates/datastorage-pvc.yaml

@@ -1,7 +1,7 @@
 {{/*
 
 ---  DO NOT EDIT THIS FILE - all configuration of HPCC platform should be done via values.yaml ----
-  
+
 ##############################################################################
 
     HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
@@ -17,12 +17,29 @@
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-    
+
 ##############################################################################
 
 */}}
 {{- $storage := (.Values.storage | default dict) -}}
+{{- $dllStorage := ($storage.dllStorage | default dict) -}}
+{{- if (and (not $dllStorage.existingClaim) (not $dllStorage.plane)) }}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" $ "label" "dll"))) }}
+{{ include "hpcc.addPVC" (dict "root" $ "name" "dllstorage" "me" $dllStorage) }}
+{{- end }}
+{{- end }}
 {{- $dataStorage := ($storage.dataStorage | default dict) -}}
 {{- if (and (not $dataStorage.existingClaim) (not $dataStorage.plane)) }}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" $ "label" "data"))) }}
 {{ include "hpcc.addPVC" (dict "root" $ "name" "datastorage" "me" $dataStorage) }}
 {{- end }}
+{{- end }}
+{{- $daliStorage := ($storage.daliStorage | default dict) -}}
+{{- if (and (not $daliStorage.existingClaim) (not $daliStorage.plane)) }}
+{{- if (not (include "hpcc.hasPlaneForLabel" (dict "root" $ "label" "dali"))) }}
+{{- $services := (.services | default dict) -}}
+{{- $modeForCoalescer := (hasKey $services "coalescer") | ternary "ReadWriteOnce" "ReadWriteMany" -}}
+{{- include "hpcc.addPVC" (dict "root" $ "name" "dalistorage" "mode" $modeForCoalescer "me" $daliStorage) -}}
+{{- end }}
+{{- end }}
+{{- include "hpcc.addPVCsFromPlanes" . }}

+ 10 - 1
helm/hpcc/values.schema.json

@@ -430,7 +430,7 @@
           "items": { "type": "string" }
         },
         "labels": {
-          "description": "a list of labels associated with this plane, e.g. lz, data. NB: if blank/unset, treated as if 'data'",
+          "description": "a list of labels associated with this plane, e.g. lz, data, dali, sasha, dlls, spill. NB: if blank/unset, treated as if 'data'",
           "type": "array",
           "items": { "type": "string" }
         },
@@ -442,6 +442,15 @@
           "description": "Number of parts sprayed by default",
           "type" : "integer"
         },
+        "storageSize": {
+          "type": "string"
+        },
+        "storageClass": {
+          "type": "string"
+        },
+        "forcePermissions": {
+          "type": "boolean"
+        },
         "cost" : {
           "description": "Costs associated with the storage and use of the plane",
           "type" : "object",

+ 18 - 6
helm/hpcc/values.yaml

@@ -40,12 +40,12 @@ global:
     moneyLocale: "en_US.UTF-8"
     perCpu: 0.126
 
-  # postJobCommand will execute at the end of a dynamically lauched K8s job,
+  # postJobCommand will execute at the end of a dynamically launched K8s job,
   # when the main entrypoint process finishes, or if the readiness probes trigger a preStop event.
   # This can be useful if injected sidecars are installed that need to be told to stop.
   # If they are not stopped, the pod continues running with the side car container only, in a "NotReady" state.
   # An example of this is the Istio envoy side car. It can be stopped with the command below.
-  # Set postJobCommandViaSidecar to true, if the command needs to run with priviledge, this will enable the command
+  # Set postJobCommandViaSidecar to true, if the command needs to run with privilege, this will enable the command
   # to run as root in a sidecar in same process space as other containers, allowing it to for example send signals
   # to processes in sidecars
 
@@ -79,6 +79,14 @@ security:
 
 ## storage:
 ##
+## 1. If a component has the storagePlane property set, then that plane will be the default data location for that component.
+## 2. If storage.dataStorage.plane is defined then that plane will be the default location
+## 3. If there is a plane definition with no label or a label of "data" then the first matching plane will be the default data location
+## 4. Otherwise the default data location will be derived from the properties of storage.dataStorage.
+##
+## If a data plane contains the storageClass property then an implicit pvc will be created for that data plane.
+## An implicit pvc is only created for storage.dataStorage if option(4) above is used to select the data location.
+##
 ## If storage.[type].existingClaim is defined, a Persistent Volume Claim must
 ## exist with that name. If an existingClaim is specified, storageClass and
 ## storageSize are not used.
@@ -107,6 +115,10 @@ storage:
   #   cost:                                 # The storage cost
   #     storageAtRest: 0.113                # Storage at rest cost: cost per GiB/month
   #   options:                              # not sure if it is needed
+  #
+  # For dynamic pvc creation:
+  #   storageClass: ''
+  #   storageSize: 1Gi
 
   dllStorage:
     storageSize: 3Gi
@@ -131,7 +143,7 @@ storage:
 ## https://cert-manager.io/docs/installation/kubernetes/#installing-with-helm
 ##
 ## The Certificate issuers are divided into "local" (those which will be used for local mutual TLS) and "public" those
-## which will be publicly accesible and therefore need to be recognized by browsers and/or other entities.
+## which will be publicly accessible and therefore need to be recognized by browsers and/or other entities.
 ##
 ## Both public and local issuers have a spec section. The contents of the "spec" are documented in the cer-manager
 ## "Issuer configuration" documentation. https://cert-manager.io/docs/configuration/#supported-issuer-types
@@ -139,8 +151,8 @@ storage:
 ## The default configuration is meant to provide reasonable functionality without additional dependencies.
 ##
 ## Public issuers can be tricky if you want browsers to recognize the certificates.  This is a complex topic outside the scope
-## of this comment.  The default for the public issuer generates self signed certifiecates. The expectation is that this will be
-## overriden by the configuration of an external certificate authority or vault in QA and production environments.
+## of this comment.  The default for the public issuer generates self signed certificates. The expectation is that this will be
+## overridden by the configuration of an external certificate authority or vault in QA and production environments.
 ##
 ## The default for the local (mTLS) issuer is designed to act as our own local certificate authority. We need only need to recognize
 ## what a component is, and that it belongs to this cluster.
@@ -173,7 +185,7 @@ certificates:
       spec:
         selfSigned: {}
 
-## The secrets section contains a set of categories, each of which contain a list of secrets.  The categories deterime which
+## The secrets section contains a set of categories, each of which contain a list of secrets.  The categories determine which
 ## components have access to the secrets.
 ## For each secret:
 ##   name is the name that is is accessed by within the platform

+ 51 - 0
testing/helm/tests/implicitplanes.yaml

@@ -0,0 +1,51 @@
+storage:
+  planes:
+  - name: my-data-plane
+    prefix: "/var/lib/HPCCSystems/hpcc-data"
+    storageSize: 1Gi
+    storageClass: ""
+  - name: my-dll-plane
+    prefix: "/var/lib/HPCCSystems/queries"
+    storageSize: 3Gi
+    storageClass: ""
+    forcePermissions: true
+    labels: [ dll ]
+  - name: my-sasha-plane
+    prefix: "/var/lib/HPCCSystems/sasha"
+    storageSize: 3Gi
+    storageClass: ""
+    forcePermissions: true
+    labels: [ unknown ]
+  - name: my-dali-plane
+    prefix: "/var/lib/HPCCSystems/dalistorage"
+    storageSize: 1Gi
+    storageClass: ""
+    labels: [ dali ]
+  - name: landingzone
+    prefix: "/var/lib/HPCCSystems/landingzone"
+    storageSize: 1Gi
+    storageClass: ""
+    labels: [ lz ]
+
+  #   name: <required>
+  #   prefix: <path>                        # Root directory for accessing the plane (if pvc defined), or url to access plane.
+  #   numDevices: 1                         # number of devices that are part of the plane
+  #   replication: nullptr                  # a list or single item indicating which planes the data should be replicated onto
+  #   includeDeviceInPath: false            # Is the device number appended to the mount for the physical path for a file?  (Only required in unusual situations)
+  #   hosts: <name>                         # Name of the host group for bare metal - must match the name of the storage plane..
+  #   secret: <secret-id>                   # what secret is required to access the files.  This could optionally become a list if required (or add secrets:).
+  #   defaultSprayParts: 4                  # The number of partitions created when spraying (default: 1)
+  #   cost:                                 # The storage cost
+  #     storageAtRest: 0.113                # Storage at rest cost: cost per GiB/month
+  #   options:                              # not sure if it is needed
+
+  #dllStorage: null
+  #daliStorage: null
+  #dataStorage: null
+
+  dllStorage:
+    plane: my-dll-plane
+  daliStorage:
+    plane: my-dali-plane
+  dataStorage:
+    plane: my-data-plane

+ 44 - 0
testing/helm/tests/implicitplanes2.yaml

@@ -0,0 +1,44 @@
+storage:
+  planes:
+  - name: my-data-plane
+    prefix: "/var/lib/HPCCSystems/hpcc-data"
+    storageSize: 1Gi
+    storageClass: ""
+  - name: my-dll-plane
+    prefix: "/var/lib/HPCCSystems/queries"
+    storageSize: 3Gi
+    storageClass: ""
+    forcePermissions: true
+    labels: [ dll ]
+  - name: my-sasha-plane
+    prefix: "/var/lib/HPCCSystems/sasha"
+    storageSize: 3Gi
+    storageClass: ""
+    forcePermissions: true
+    labels: [ unknown ]
+  - name: my-dali-plane
+    prefix: "/var/lib/HPCCSystems/dalistorage"
+    storageSize: 1Gi
+    storageClass: ""
+    labels: [ dali ]
+  - name: landingzone
+    prefix: "/var/lib/HPCCSystems/landingzone"
+    storageSize: 1Gi
+    storageClass: ""
+    labels: [ lz ]
+
+  #   name: <required>
+  #   prefix: <path>                        # Root directory for accessing the plane (if pvc defined), or url to access plane.
+  #   numDevices: 1                         # number of devices that are part of the plane
+  #   replication: nullptr                  # a list or single item indicating which planes the data should be replicated onto
+  #   includeDeviceInPath: false            # Is the device number appended to the mount for the physical path for a file?  (Only required in unusual situations)
+  #   hosts: <name>                         # Name of the host group for bare metal - must match the name of the storage plane..
+  #   secret: <secret-id>                   # what secret is required to access the files.  This could optionally become a list if required (or add secrets:).
+  #   defaultSprayParts: 4                  # The number of partitions created when spraying (default: 1)
+  #   cost:                                 # The storage cost
+  #     storageAtRest: 0.113                # Storage at rest cost: cost per GiB/month
+  #   options:                              # not sure if it is needed
+
+  dllStorage: null
+  daliStorage: null
+  dataStorage: null