Bläddra i källkod

Allow using host path or ix volume for persistent data storage

Waqar Ahmed 5 år sedan
förälder
incheckning
8e719a4787

+ 51 - 0
test/nextcloud/2.3.2/questions.yaml

@@ -3,6 +3,8 @@ groups:
     description: "Image to be used for container"
   - name: "Nextcloud Configuration"
     description: "Configuration details for Nextcloud workload"
+  - name: "Storage Configuration"
+    description: "Configure Storage for Nextcloud"
 
 questions:
   # Image related
@@ -101,3 +103,52 @@ questions:
             max: 65535
             default: 9000
             required: true
+
+  - variable: configureiXVolume
+    label: "Configure iX Volume"
+    group: "Storage Configuration"
+    description: "Use iX Volume for persistent storage"
+    schema:
+      type: boolean
+      default: true
+      required: true
+      show_subquestions_if: true
+      subquestions:
+        - variable: volume
+          label: "Configure iXVolume"
+          group: "Storage Configuration"
+          schema:
+            type: dict
+            $ref:
+              - "normalize/ixVolume"
+            attrs:
+              - variable: mountPath
+                label: "Mount Path"
+                description: "Path where the volume will be mounted inside the pod"
+                schema:
+                  type: path
+                  editable: false
+                  default: "/var/www"
+              - variable: datasetName
+                label: "Dataset Name"
+                schema:
+                  type: string
+                  required: true
+
+  - variable: configureHostPath
+    label: "Configure Host Path for storage"
+    description: "Use a path on host for persistent data storage"
+    group: "Storage Configuration"
+    schema:
+      type: boolean
+      default: false
+      required: true
+      show_if: [["configureiXVolume", "=", false]]
+      show_subquestions_if: true
+      subquestions:
+        - variable: volumeHostPath
+          label: "Host Path"
+          group: "Storage Configuration"
+          schema:
+            type: hostpath
+            required: true

+ 14 - 0
test/nextcloud/2.3.2/templates/_helpers.tpl

@@ -47,3 +47,17 @@ Create chart name and version as used by the chart label.
 {{- define "nextcloud.chart" -}}
 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
 {{- end -}}
+
+{{/*
+Retrieve host path defined in volume
+*/}}
+{{- define "configuredHostPath" -}}
+{{- if .Values.configureiXVolume -}}
+{{- $volDict := first .Values.ixVolumes -}}
+{{- $volDict.hostPath -}}
+{{- else if .Values.configureHostPath -}}
+{{- .Values.volumeHostPath -}}
+{{- else -}}
+{{- printf "" -}}
+{{- end -}}
+{{- end -}}

+ 3 - 0
test/nextcloud/2.3.2/templates/deployment.yaml

@@ -328,6 +328,9 @@ spec:
       {{- if .Values.persistence.enabled }}
         persistentVolumeClaim:
           claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
+      {{- else if ne (include "configuredHostPath" .) "" }}
+        hostPath:
+          path: {{ template "configuredHostPath" . }}
       {{- else }}
         emptyDir: {}
       {{- end }}