From c3c8f25c62f377b7a247c67682daab4e50779ddd Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Wed, 7 Oct 2020 00:49:24 +0500 Subject: [PATCH] Add support for PVC's in ix-chart --- charts/ix-chart/2009.0.1/questions.yaml | 25 +++++++++++++++++++ .../2009.0.1/templates/deployment.yaml | 13 ++++++++-- .../templates/persistent-volume-claims.yaml | 14 +++++++++++ charts/ix-chart/2009.0.1/values.yaml | 1 + 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 charts/ix-chart/2009.0.1/templates/persistent-volume-claims.yaml diff --git a/charts/ix-chart/2009.0.1/questions.yaml b/charts/ix-chart/2009.0.1/questions.yaml index 2899863700..8885c36a93 100644 --- a/charts/ix-chart/2009.0.1/questions.yaml +++ b/charts/ix-chart/2009.0.1/questions.yaml @@ -162,6 +162,7 @@ # Host path based volumes - variable: hostPathVolumes label: "Host Path Volumes" + group: "Storage" schema: type: list items: @@ -186,3 +187,27 @@ schema: type: boolean default: false + +# Persistent Volume Claims +- variable: persistentVolumeClaims + label: "Persistent Volume Claims" + group: "Storage" + schema: + type: list + items: + - variable: persistentVolumeClaim + label: "Persistent Volume Claim Configuration" + schema: + type: dict + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + required: true + - variable: capacity + label: "Volume Capacity" + schema: + type: int + required: true diff --git a/charts/ix-chart/2009.0.1/templates/deployment.yaml b/charts/ix-chart/2009.0.1/templates/deployment.yaml index 0e92215b15..40f78f6819 100644 --- a/charts/ix-chart/2009.0.1/templates/deployment.yaml +++ b/charts/ix-chart/2009.0.1/templates/deployment.yaml @@ -20,13 +20,17 @@ spec: spec: containers: - name: {{ .Chart.Name }} - {{- if .Values.hostPathVolumes }} + {{- if or .Values.hostPathVolumes .Values.persistentVolumeClaims }} volumeMounts: {{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} - mountPath: {{ $hostPathConfiguration.mountPath }} name: ix-host-path-{{ $.Release.Name }}-{{ $index }} readOnly: {{ $hostPathConfiguration.readOnly }} {{- end }} + {{- range $index, $claim := .Values.persistentVolumeClaims }} + - mountPath: {{ $claim.mountPath }} + name: ix-pv-{{ $.Release.Name }}-{{ $index }} + {{- end }} {{- end }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} @@ -51,11 +55,16 @@ spec: value: {{ .value | quote }} {{- end }} {{- end }} - {{- if .Values.hostPathVolumes }} + {{- if or .Values.persistentVolumeClaims .Values.hostPathVolumes }} volumes: {{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} - name: ix-host-path-{{ $.Release.Name }}-{{ $index }} hostPath: path: {{ $hostPathConfiguration.hostPath }} {{- end }} + {{- range $index, $claim := .Values.persistentVolumeClaims }} + - name: ix-pv-{{ $.Release.Name }}-{{ $index }} + persistentVolumeClaim: + claimName: ix-pv-claim-{{ $.Release.Name }}-{{ $index }} + {{- end }} {{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/persistent-volume-claims.yaml b/charts/ix-chart/2009.0.1/templates/persistent-volume-claims.yaml new file mode 100644 index 0000000000..0f082766fd --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/persistent-volume-claims.yaml @@ -0,0 +1,14 @@ +{{- range $index, $claim := .Values.persistentVolumeClaims }} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: ix-pv-claim-{{ $.Release.Name }}-{{ $index }} +spec: + storageClassName: ix-storage-class-{{ $.Release.Name }} + resources: + requests: + storage: {{ $claim.capacity }} + accessModes: + - ReadWriteMany +{{- end }} diff --git a/charts/ix-chart/2009.0.1/values.yaml b/charts/ix-chart/2009.0.1/values.yaml index c8db8d4398..4150878391 100644 --- a/charts/ix-chart/2009.0.1/values.yaml +++ b/charts/ix-chart/2009.0.1/values.yaml @@ -16,3 +16,4 @@ externalInterfaces: [] # Storage related configuration hostPathVolumes: [] +persistentVolumeClaims: []