Browse Source

HPCC-23646 Use default storageclass for persistent storage volumes

Use standard conventions for persistent storage names/labels, as specified at
https://github.com/helm/charts/blob/master/REVIEW_GUIDELINES.md

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 years ago
parent
commit
58b77689dd

+ 34 - 4
dockerfiles/hpcc/templates/_util.tpl

@@ -1,3 +1,35 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "hpcc.utils.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "hpcc.utils.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "hpcc.utils.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
 {{- /* Translate a port list to a comma-separated list */ -}}
 {{- define "hpcc.utils.portListToCommas" -}}
  {{- if hasPrefix "[]" (typeOf .) -}}
@@ -58,14 +90,12 @@ data:
 
 {{- /* Add standard volumes for a component */ -}}
 {{- define "hpcc.utils.addVolumes" -}}
-volumes:
-{{ include "hpcc.utils.addConfigVolume" . }}
 - name: dllserver-pv-storage
   persistentVolumeClaim:
-    claimName: dllserver-pv-claim
+    claimName: {{ .Values.global.dllserver.existingClaim | default (printf "%s-dllserver-pv-claim" (include "hpcc.utils.fullname" .)) }}
 - name: datastorage-pv
   persistentVolumeClaim:
-    claimName: datastorage-pv-claim
+    claimName: {{ .Values.global.dataStorage.existingClaim | default (printf "%s-datastorage-pv-claim" (include "hpcc.utils.fullname" .)) }}
 {{- end -}}
 
 {{- /* Add standard volume mounts for a component */ -}}

+ 8 - 1
dockerfiles/hpcc/templates/datastorage.yaml

@@ -1,10 +1,17 @@
+{{- if (not .Values.global.dataStorage.existingClaim) }}
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
-  name: datastorage-pv-claim
+  name: {{ printf "%s-datastorage-pv-claim" (include "hpcc.utils.fullname" .) }}
+  labels:
+    app.kubernetes.io/name: {{ printf "%s-datastorage-pv-claim" (include "hpcc.utils.fullname" .) }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    helm.sh/chart: {{ include "hpcc.utils.chart" . }}
 spec:
   accessModes:
     - ReadWriteMany
   resources:
     requests:
       storage: {{ .Values.global.dataStorage.storageSize }}
+{{- end }}

+ 8 - 1
dockerfiles/hpcc/templates/dllserver-claim.yaml

@@ -1,10 +1,17 @@
+{{- if (not .Values.global.dllserver.existingClaim) }}
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
-  name: dllserver-pv-claim
+  name: {{ printf "%s-dllserver-pv-claim" (include "hpcc.utils.fullname" .) }}
+  labels:
+    app.kubernetes.io/name: {{ printf "%s-dllserver-pv-claim" (include "hpcc.utils.fullname" .) }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    helm.sh/chart: {{ include "hpcc.utils.chart" . }}
 spec:
   accessModes:
     - ReadWriteMany
   resources:
     requests:
       storage: {{ .Values.global.dllserver.storageSize }}
+{{- end }}

+ 6 - 2
dockerfiles/hpcc/templates/eclagent.yaml

@@ -22,7 +22,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "eclagent") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 {{- include "hpcc.utils.generateConfigMap" (dict "root" $ "me" .) }}
   jobspec.yaml: |
@@ -51,7 +53,9 @@ spec:
                         %args
                      ]
 {{ include "hpcc.utils.addVolumeMounts" . | indent 12 }}
-{{ include "hpcc.utils.addVolumes" . | indent 10 }}
+          volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 10 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 10 }}
           restartPolicy: Never
       backoffLimit: 0
       

+ 6 - 2
dockerfiles/hpcc/templates/eclccserver.yaml

@@ -24,7 +24,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "eclccserver") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 {{- include "hpcc.utils.generateConfigMap" (dict "root" $ "me" .) }}
   jobspec.yaml: |
@@ -53,7 +55,9 @@ spec:
                         %args
                      ]
 {{ include "hpcc.utils.addVolumeMounts" . | indent 12 }}
-{{ include "hpcc.utils.addVolumes" . | indent 10 }}
+          volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 10 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 10 }}
           restartPolicy: Never
       backoffLimit: 0
       

+ 3 - 1
dockerfiles/hpcc/templates/esp.yaml

@@ -21,7 +21,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "esp") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 {{- include "hpcc.utils.generateConfigMap" (dict "root" $ "me" .) -}}
 ---

+ 3 - 1
dockerfiles/hpcc/templates/localroxie.yaml

@@ -27,7 +27,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "roxie") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 {{- include "hpcc.utils.generateConfigMap" (dict "root" $ "me" $roxie ) -}}
 ---

+ 6 - 2
dockerfiles/hpcc/templates/roxie.yaml

@@ -77,7 +77,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" $roxie "imagename" "roxie") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 
 {{ end -}}
@@ -112,7 +114,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" $roxie "imagename" "roxie") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" $roxie | indent 8 }}
-{{ include "hpcc.utils.addVolumes" $roxie | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 
 ---
 

+ 6 - 11
dockerfiles/hpcc/templates/thor.yaml

@@ -29,7 +29,9 @@ spec:
               ]
 {{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "thormaster") | indent 8 }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 8 }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 apiVersion: apps/v1
 kind: Deployment
@@ -57,16 +59,9 @@ spec:
           ports:
             - containerPort: {{ $slavePort }}
 {{ include "hpcc.utils.addVolumeMounts" . | indent 10 }}
-        {{- if $thor.startDafilesrv | default false }}
-        - name: {{ printf "%s-dafilesrv" $slaveName | quote }}
-{{ include "hpcc.utils.addImageAttrs" (dict "root" $ "me" . "imagename" "thorslave") | indent 10 }}
-          command: ["dafilesrv"]
-          ports:
-            - containerPort: 7100
-          volumeMounts:
-{{ include "hpcc.utils.addDataVolumeMount" . | indent 12 }}
-        {{- end }}
-{{ include "hpcc.utils.addVolumes" . | indent 6 }}
+      volumes:
+{{ include "hpcc.utils.addConfigVolume" . | indent 6 }}
+{{ include "hpcc.utils.addVolumes" $ | indent 6 }}
 ---
 apiVersion: v1
 kind: Service

+ 16 - 1
dockerfiles/hpcc/values.yaml

@@ -5,10 +5,25 @@ global:
   
   dllserver:
     storageSize: 3Gi
+    ## If defined, storageClassName: <storageClass>
+    ## If set to "-", storageClassName: "", which disables dynamic provisioning
+    ## If undefined (the default) or set to null, no storageClassName spec is
+    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
+    ##   GKE, AWS & OpenStack)
+    ##
+    storageClass: ""
+    # existingClaim: ""
   
   dataStorage:
     storageSize: 1G
-    startDafilesrv: false # Temporary until non attached storage functionality added
+    ## If defined, storageClassName: <storageClass>
+    ## If set to "-", storageClassName: "", which disables dynamic provisioning
+    ## If undefined (the default) or set to null, no storageClassName spec is
+    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
+    ##   GKE, AWS & OpenStack)
+    ##
+    storageClass: ""
+    # existingClaim: ""
 
   image:
     # This should probably say "latest" or "stable" in the example script, but set to a specific version in production systems