mirror of
https://github.com/truenas/charts.git
synced 2026-02-03 02:23:49 +08:00
NAS-123350 / 24.04 / Add support in common for nfs/smb pvc (#1422)
* Empty-Commit * temp commit * make sure that we use the pv * typo * add validation * typo * cleanup validation and add secret for smb * revert * add some tets * add more tests * add more tests * more tests * rename to share * rename * moar tests * clean * add some docs * fix name uniqueness and tests * make mountOptions validation a bit better * update docs
This commit is contained in:
@@ -12,7 +12,7 @@ icon: https://localhost/icon
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../common
|
||||
version: ~1.0.0
|
||||
version: ~1.1.0
|
||||
maintainers:
|
||||
- name: truenas
|
||||
url: https://www.truenas.com/
|
||||
|
||||
@@ -71,3 +71,34 @@ persistence:
|
||||
hostPath: /usr
|
||||
mountPath: /hptest
|
||||
hostPathType: ""
|
||||
|
||||
pvc-stock:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /pvcstock
|
||||
|
||||
pvc-size:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /pvcsize
|
||||
size: 1Gi
|
||||
|
||||
pvc-readonly:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /pvcro
|
||||
readOnly: true
|
||||
|
||||
pvc-labeled:
|
||||
enabled: true
|
||||
labels:
|
||||
labelexample1: labelvalue2
|
||||
type: pvc
|
||||
mountPath: /pvclabeled
|
||||
|
||||
pvc-sc-empty:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /pvcscempty
|
||||
readOnly: false
|
||||
storageClass: ""
|
||||
|
||||
@@ -55,8 +55,24 @@ tests:
|
||||
type: emptyDir
|
||||
mountPath: "{{ .Values.some_path }}"
|
||||
targetSelectAll: true
|
||||
nfs-vol-pvc:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /my-path
|
||||
mountPath: /nfs-mount
|
||||
targetSelectAll: true
|
||||
smb-vol-pvc:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: my-share
|
||||
username: my-user
|
||||
password: my-pass
|
||||
mountPath: /smb-mount
|
||||
targetSelectAll: true
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: &deploymentDoc 5
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -69,6 +85,20 @@ tests:
|
||||
name: shared-vol
|
||||
mountPath: /some/path
|
||||
readOnly: false
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: nfs-vol-pvc
|
||||
mountPath: /nfs-mount
|
||||
readOnly: false
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: smb-vol-pvc
|
||||
mountPath: /smb-mount
|
||||
readOnly: false
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
@@ -76,7 +106,21 @@ tests:
|
||||
name: shared-vol
|
||||
mountPath: /some/path
|
||||
readOnly: false
|
||||
- documentIndex: &jobDoc 1
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
content:
|
||||
name: nfs-vol-pvc
|
||||
mountPath: /nfs-mount
|
||||
readOnly: false
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
content:
|
||||
name: smb-vol-pvc
|
||||
mountPath: /smb-mount
|
||||
readOnly: false
|
||||
- documentIndex: &jobDoc 6
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *jobDoc
|
||||
@@ -89,6 +133,20 @@ tests:
|
||||
name: shared-vol
|
||||
mountPath: /some/path
|
||||
readOnly: false
|
||||
- documentIndex: *jobDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: nfs-vol-pvc
|
||||
mountPath: /nfs-mount
|
||||
readOnly: false
|
||||
- documentIndex: *jobDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: smb-vol-pvc
|
||||
mountPath: /smb-mount
|
||||
readOnly: false
|
||||
- documentIndex: *jobDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
@@ -96,6 +154,20 @@ tests:
|
||||
name: shared-vol
|
||||
mountPath: /some/path
|
||||
readOnly: false
|
||||
- documentIndex: *jobDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
content:
|
||||
name: nfs-vol-pvc
|
||||
mountPath: /nfs-mount
|
||||
readOnly: false
|
||||
- documentIndex: *jobDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[1].volumeMounts
|
||||
content:
|
||||
name: smb-vol-pvc
|
||||
mountPath: /smb-mount
|
||||
readOnly: false
|
||||
|
||||
- it: should pass with volume on primary workload and container
|
||||
set:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
suite: ix-zfs-pvc data name test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should create ix-zfs-pvc
|
||||
set:
|
||||
global:
|
||||
ixChartContext:
|
||||
storageClassName: ix-storage-class-releasename
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
asserts:
|
||||
- documentIndex: &pvcDoc 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: ix-storage-class-releasename
|
||||
|
||||
- it: should ignore storageClass defined on the object on type ix-zfs-pvc
|
||||
set:
|
||||
global:
|
||||
ixChartContext:
|
||||
storageClassName: ix-storage-class-releasename
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
storageClass: some-storage-class
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: ix-storage-class-releasename
|
||||
195
library/common-test/tests/persistence/pv_data_test.yaml
Normal file
195
library/common-test/tests/persistence/pv_data_test.yaml
Normal file
@@ -0,0 +1,195 @@
|
||||
suite: pv data test
|
||||
templates:
|
||||
- common.yaml
|
||||
release:
|
||||
namespace: release-namespace
|
||||
tests:
|
||||
- it: should create nfs pv with csi
|
||||
set:
|
||||
version: 4.1
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /my-path
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server2
|
||||
share: /my-path2
|
||||
mountOptions:
|
||||
- key: hard
|
||||
- key: nfsvers
|
||||
value: '{{ .Values.version }}'
|
||||
asserts:
|
||||
- documentIndex: &pvDoc 0
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
persistentVolumeReclaimPolicy: Delete
|
||||
storageClassName: release-name-common-test-my-volume1-1088882375
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
csi:
|
||||
driver: nfs.csi.k8s.io
|
||||
volumeHandle: my-server/my-path#release-name-common-test-my-volume1-1088882375
|
||||
volumeAttributes:
|
||||
server: my-server
|
||||
share: /my-path
|
||||
- documentIndex: &pvcDoc 1
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
storageClassName: release-name-common-test-my-volume1-1088882375
|
||||
- documentIndex: &otherPvDoc 2
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *otherPvDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
persistentVolumeReclaimPolicy: Delete
|
||||
storageClassName: release-name-common-test-my-volume2-1303447339
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
mountOptions:
|
||||
- hard
|
||||
- nfsvers=4.1
|
||||
csi:
|
||||
driver: nfs.csi.k8s.io
|
||||
volumeHandle: my-server2/my-path2#release-name-common-test-my-volume2-1303447339
|
||||
volumeAttributes:
|
||||
server: my-server2
|
||||
share: /my-path2
|
||||
|
||||
- it: should create smb pv with csi
|
||||
set:
|
||||
version: "3.0"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: my-share
|
||||
username: my-user
|
||||
password: my-password
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server2
|
||||
share: my-share2
|
||||
username: my-user2
|
||||
password: my-password2
|
||||
mountOptions:
|
||||
- key: hard
|
||||
- key: uid
|
||||
value: 99999999999
|
||||
- key: vers
|
||||
value: '{{ .Values.version }}'
|
||||
asserts:
|
||||
- documentIndex: &secretDoc 0
|
||||
isKind:
|
||||
of: Secret
|
||||
- documentIndex: *secretDoc
|
||||
equal:
|
||||
path: stringData
|
||||
value:
|
||||
username: my-user
|
||||
password: my-password
|
||||
- documentIndex: &pvDoc 1
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
persistentVolumeReclaimPolicy: Delete
|
||||
storageClassName: release-name-common-test-my-volume1-1117390590
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
csi:
|
||||
driver: smb.csi.k8s.io
|
||||
volumeHandle: my-server/my-share#release-name-common-test-my-volume1-1117390590
|
||||
volumeAttributes:
|
||||
source: //my-server/my-share
|
||||
nodeStageSecretRef:
|
||||
name: release-name-common-test-my-volume1-1117390590
|
||||
namespace: release-namespace
|
||||
- documentIndex: &pvcDoc 2
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
storageClassName: release-name-common-test-my-volume1-1117390590
|
||||
- documentIndex: &otherSecretDoc 3
|
||||
isKind:
|
||||
of: Secret
|
||||
- documentIndex: *otherSecretDoc
|
||||
equal:
|
||||
path: stringData
|
||||
value:
|
||||
username: my-user2
|
||||
password: my-password2
|
||||
- documentIndex: &otherPvDoc 4
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *otherPvDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
persistentVolumeReclaimPolicy: Delete
|
||||
storageClassName: release-name-common-test-my-volume2-1335560034
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
mountOptions:
|
||||
- hard
|
||||
- uid=99999999999
|
||||
- vers=3.0
|
||||
csi:
|
||||
driver: smb.csi.k8s.io
|
||||
volumeHandle: my-server2/my-share2#release-name-common-test-my-volume2-1335560034
|
||||
volumeAttributes:
|
||||
source: //my-server2/my-share2
|
||||
nodeStageSecretRef:
|
||||
name: release-name-common-test-my-volume2-1335560034
|
||||
namespace: release-namespace
|
||||
- documentIndex: &otherPvcDoc 5
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *otherPvcDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
storageClassName: release-name-common-test-my-volume2-1335560034
|
||||
228
library/common-test/tests/persistence/pv_metadata_test.yaml
Normal file
228
library/common-test/tests/persistence/pv_metadata_test.yaml
Normal file
@@ -0,0 +1,228 @@
|
||||
suite: pv metadata test
|
||||
templates:
|
||||
- common.yaml
|
||||
chart:
|
||||
appVersion: &appVer v9.9.9
|
||||
tests:
|
||||
- it: should pass with pv created with labels and annotations (nfs-pv-pvc)
|
||||
set:
|
||||
label1: label1
|
||||
label2: global_label2
|
||||
annotation1: annotation1
|
||||
annotation2: global_annotation2
|
||||
global:
|
||||
labels:
|
||||
g_label1: global_label1
|
||||
g_label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: "{{ .Values.annotation2 }}"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /my-path
|
||||
labels:
|
||||
label1: "{{ .Values.label1 }}"
|
||||
label2: label2
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
asserts:
|
||||
- documentIndex: &pvDoc 0
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
annotation1: annotation1
|
||||
annotation2: annotation2
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
pv.kubernetes.io/provisioned-by: nfs.csi.k8s.io
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
|
||||
- it: should pass with pvc created with retain set to true (nfs-pv-pvc)
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /my-path
|
||||
retain: true
|
||||
asserts:
|
||||
- documentIndex: *pvDoc
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
"helm.sh/resource-policy": keep
|
||||
pv.kubernetes.io/provisioned-by: nfs.csi.k8s.io
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
|
||||
- it: should pass with pv created with labels and annotations (smb-pv-pvc)
|
||||
set:
|
||||
label1: label1
|
||||
label2: global_label2
|
||||
annotation1: annotation1
|
||||
annotation2: global_annotation2
|
||||
global:
|
||||
labels:
|
||||
g_label1: global_label1
|
||||
g_label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: "{{ .Values.annotation2 }}"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: my-path
|
||||
username: my-user
|
||||
password: my-password
|
||||
labels:
|
||||
label1: "{{ .Values.label1 }}"
|
||||
label2: label2
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
asserts:
|
||||
- documentIndex: &secretDoc 0
|
||||
isKind:
|
||||
of: Secret
|
||||
- documentIndex: *secretDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *secretDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
annotation1: annotation1
|
||||
annotation2: annotation2
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
- documentIndex: *secretDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: &pvDoc 1
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
annotation1: annotation1
|
||||
annotation2: annotation2
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
pv.kubernetes.io/provisioned-by: smb.csi.k8s.io
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
|
||||
- it: should pass with pvc created with retain set to true (smb-pv-pvc)
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: my-path
|
||||
username: my-user
|
||||
password: my-password
|
||||
retain: true
|
||||
asserts:
|
||||
- documentIndex: *secretDoc
|
||||
isKind:
|
||||
of: Secret
|
||||
- documentIndex: *secretDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *secretDoc
|
||||
isNull:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *pvDoc
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
"helm.sh/resource-policy": keep
|
||||
pv.kubernetes.io/provisioned-by: smb.csi.k8s.io
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
70
library/common-test/tests/persistence/pv_name_test.yaml
Normal file
70
library/common-test/tests/persistence/pv_name_test.yaml
Normal file
@@ -0,0 +1,70 @@
|
||||
suite: pv name test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should generate correct name
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /some/path
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: some/path
|
||||
username: my-user
|
||||
password: my-password
|
||||
asserts:
|
||||
- documentIndex: &pvDoc 0
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1-1342834583
|
||||
- documentIndex: &pvcDoc 1
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1-1342834583
|
||||
- documentIndex: &secretDoc 2
|
||||
isKind:
|
||||
of: Secret
|
||||
- documentIndex: *secretDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *secretDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2-1247545192
|
||||
- documentIndex: &pvDoc 3
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2-1247545192
|
||||
- documentIndex: &otherPvcDoc 4
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *otherPvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *otherPvcDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2-1247545192
|
||||
171
library/common-test/tests/persistence/pvc_data_test.yaml
Normal file
171
library/common-test/tests/persistence/pvc_data_test.yaml
Normal file
@@ -0,0 +1,171 @@
|
||||
suite: pvc data name test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should create pvc
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
asserts:
|
||||
- documentIndex: &pvcDoc 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.accessModes
|
||||
value:
|
||||
- ReadWriteOnce
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.resources.requests.storage
|
||||
value: 1Gi
|
||||
- documentIndex: *pvcDoc
|
||||
isNull:
|
||||
path: spec.volumeName
|
||||
- documentIndex: *pvcDoc
|
||||
isNull:
|
||||
path: spec.storageClassName
|
||||
|
||||
- it: should not create pvc when existingClaim is set
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
existingClaim: some-existing-claim
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
of: 0
|
||||
|
||||
- it: should create pvc with accessModes set as string
|
||||
set:
|
||||
some_mode: ReadWriteMany
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
accessModes: "{{ .Values.some_mode }}"
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.accessModes
|
||||
value:
|
||||
- ReadWriteMany
|
||||
|
||||
- it: should create pvc with accessModes set as list
|
||||
set:
|
||||
some_mode: ReadWriteMany
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
accessModes:
|
||||
- "{{ .Values.some_mode }}"
|
||||
- ReadWriteOnce
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.accessModes
|
||||
value:
|
||||
- ReadWriteMany
|
||||
- ReadWriteOnce
|
||||
|
||||
- it: should create pvc with size set
|
||||
set:
|
||||
some_size: 20Gi
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
size: "{{ .Values.some_size }}"
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.resources.requests.storage
|
||||
value: 20Gi
|
||||
|
||||
- it: should create pvc with volumeName set
|
||||
set:
|
||||
some_vol_name: some-pv-name
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
volumeName: "{{ .Values.some_vol_name }}"
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.volumeName
|
||||
value: some-pv-name
|
||||
|
||||
- it: should create pvc with storageClass set "-"
|
||||
set:
|
||||
some_storage_class: "-"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
storageClass: "{{ .Values.some_storage_class }}"
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: ""
|
||||
|
||||
- it: should create pvc with storageClass set
|
||||
set:
|
||||
some_storage_class: "some-storage-class"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
storageClass: "{{ .Values.some_storage_class }}"
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: some-storage-class
|
||||
|
||||
- it: should create pvc with storageClass not set, but have fallbackDefaults set
|
||||
set:
|
||||
fallbackDefaults:
|
||||
storageClass: some-storage-class
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: some-storage-class
|
||||
89
library/common-test/tests/persistence/pvc_metadata_test.yaml
Normal file
89
library/common-test/tests/persistence/pvc_metadata_test.yaml
Normal file
@@ -0,0 +1,89 @@
|
||||
suite: pvc metadata test
|
||||
templates:
|
||||
- common.yaml
|
||||
chart:
|
||||
appVersion: &appVer v9.9.9
|
||||
tests:
|
||||
- it: should pass with pvc created with labels and annotations
|
||||
set:
|
||||
label1: label1
|
||||
label2: global_label2
|
||||
annotation1: annotation1
|
||||
annotation2: global_annotation2
|
||||
global:
|
||||
labels:
|
||||
g_label1: global_label1
|
||||
g_label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: "{{ .Values.annotation2 }}"
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
labels:
|
||||
label1: "{{ .Values.label1 }}"
|
||||
label2: label2
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
type: pvc
|
||||
asserts:
|
||||
- documentIndex: &pvcDoc 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
annotation1: annotation1
|
||||
annotation2: annotation2
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
|
||||
- it: should pass with pvc created with retain set to true
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
retain: true
|
||||
asserts:
|
||||
- documentIndex: *pvcDoc
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
"helm.sh/resource-policy": keep
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/name: common-test
|
||||
34
library/common-test/tests/persistence/pvc_name_test.yaml
Normal file
34
library/common-test/tests/persistence/pvc_name_test.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
suite: pvc name test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should generate correct name
|
||||
set:
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: pvc
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: pvc
|
||||
asserts:
|
||||
- documentIndex: &pvcDoc 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *pvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *pvcDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1
|
||||
- documentIndex: &otherPvcDoc 1
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *otherPvcDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *otherPvcDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2
|
||||
@@ -2,6 +2,26 @@ suite: persistence validation test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should fail with annotations not a dict
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
annotations: not-a-dict
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected <annotations> to be a dictionary, but got [string]
|
||||
|
||||
- it: should fail with labels not a dict
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
labels: not-a-dict
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected <labels> to be a dictionary, but got [string]
|
||||
|
||||
- it: should fail with pod targetSelector not a map
|
||||
set:
|
||||
workload:
|
||||
@@ -32,7 +52,32 @@ tests:
|
||||
type: not-a-type
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected <type> to be one of [emptyDir, hostPath, ixVolume, secret, configmap, device], but got [not-a-type]
|
||||
errorMessage: Persistence - Expected <type> to be one of [smb-pv-pvc, nfs-pv-pvc, ix-zfs-pvc, pvc, emptyDir, hostPath, ixVolume, secret, configmap, device], but got [not-a-type]
|
||||
|
||||
- it: should fail with invalid accessMode
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
accessModes:
|
||||
- not-an-access-mode
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistent Volume Claim - Expected <accessModes> entry to be one of [ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePod], but got [not-an-access-mode]
|
||||
|
||||
- it: should fail without storageClassName in ixChartContext
|
||||
set:
|
||||
global:
|
||||
ixChartContext:
|
||||
storageClassName: ""
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistent Volume Claim - Expected non-empty <global.ixChartContext.storageClassName> on [ix-zfs-pvc] type
|
||||
|
||||
- it: should fail with non-existent configmap
|
||||
set:
|
||||
@@ -90,3 +135,198 @@ tests:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected secret [my-non-existent-secret] defined in <objectName> to exist
|
||||
|
||||
- it: should fail without server on nfs-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Expected <server> to be non-empty
|
||||
|
||||
- it: should fail without share on nfs-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server.local
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Expected <share> to be non-empty
|
||||
|
||||
- it: should fail without server on smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected <server> to be non-empty
|
||||
|
||||
- it: should fail without share on smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected <share> to be non-empty
|
||||
|
||||
- it: should fail without CSI when in ixChartContext on smb-pv-pvc
|
||||
set:
|
||||
global:
|
||||
ixChartContext: {}
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Not supported CSI
|
||||
|
||||
- it: should fail without CSI when in ixChartContext on nfs-pv-pvc
|
||||
set:
|
||||
global:
|
||||
ixChartContext: {}
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server.local
|
||||
share: /share
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Not supported CSI
|
||||
|
||||
- it: should fail without username smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected <username> to be non-empty
|
||||
|
||||
- it: should fail without password on smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
username: my-user
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected <password> to be non-empty
|
||||
|
||||
- it: should fail with server starting with // on smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: //my-server.local
|
||||
share: share
|
||||
username: my-user
|
||||
password: my-password
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Did not expect <server> to start with [//]
|
||||
|
||||
- it: should fail with share starting with / on smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: /share
|
||||
username: my-user
|
||||
password: my-password
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Did not expect <share> to start with [/]
|
||||
|
||||
- it: should fail with share starting with / on nfs-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Expected <share> to start with [/]
|
||||
|
||||
- it: should fail with empty key on mountOptions in nfs-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server.local
|
||||
share: /share
|
||||
mountOptions:
|
||||
- key: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Expected key in <mountOptions> to be non-empty
|
||||
|
||||
- it: should fail with empty key on mountOptions in smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
username: my-user
|
||||
password: my-password
|
||||
mountOptions:
|
||||
- key: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected key in <mountOptions> to be non-empty
|
||||
|
||||
- it: should fail with item in mountOptions not a map in smb-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server.local
|
||||
share: share
|
||||
username: my-user
|
||||
password: my-password
|
||||
mountOptions:
|
||||
- not-a-map
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: SMB CSI - Expected <mountOption> item to be a dict, but got [string]
|
||||
|
||||
- it: should fail with item in mountOptions not a map in nfs-pv-pvc
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server.local
|
||||
share: /share
|
||||
mountOptions:
|
||||
- not-a-map
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: NFS CSI - Expected <mountOption> item to be a dict, but got [string]
|
||||
|
||||
30
library/common-test/tests/pod/volume_ix-zfs-pvc_test.yaml
Normal file
30
library/common-test/tests/pod/volume_ix-zfs-pvc_test.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
suite: pod ix-zfs-pvc volume test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with pvc volume
|
||||
set:
|
||||
global:
|
||||
ixChartContext:
|
||||
storageClassName: ix-storage-class-releasename
|
||||
workload:
|
||||
workload-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: pvc-vol
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-pvc-vol
|
||||
55
library/common-test/tests/pod/volume_nfs-pv-pvc_test.yaml
Normal file
55
library/common-test/tests/pod/volume_nfs-pv-pvc_test.yaml
Normal file
@@ -0,0 +1,55 @@
|
||||
suite: pod nfs-pv-pvc volume test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with nfs-pv-pvc volume
|
||||
set:
|
||||
workload:
|
||||
workload-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server
|
||||
share: /my-path
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
server: my-server2
|
||||
share: /my-path2
|
||||
asserts:
|
||||
- documentIndex: &pvDoc 0
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1-1088882375
|
||||
- documentIndex: &otherPvDoc 2
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *otherPvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2-1303447339
|
||||
- documentIndex: &deploymentDoc 4
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: my-volume1
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-my-volume1-1088882375
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: my-volume2
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-my-volume2-1303447339
|
||||
52
library/common-test/tests/pod/volume_pvc_test.yaml
Normal file
52
library/common-test/tests/pod/volume_pvc_test.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
suite: pod pvc volume test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with pvc volume
|
||||
set:
|
||||
workload:
|
||||
workload-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: pvc
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: pvc-vol
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-pvc-vol
|
||||
|
||||
- it: should pass with pvc volume with existing claim
|
||||
set:
|
||||
workload:
|
||||
workload-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: pvc
|
||||
existingClaim: some-existing-claim
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: pvc-vol
|
||||
persistentVolumeClaim:
|
||||
claimName: some-existing-claim
|
||||
59
library/common-test/tests/pod/volume_smb-pv-pvc_test.yaml
Normal file
59
library/common-test/tests/pod/volume_smb-pv-pvc_test.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
suite: pod smb-pv-pvc volume test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with smb-pv-pvc volume
|
||||
set:
|
||||
workload:
|
||||
workload-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
my-volume1:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server
|
||||
share: my-share
|
||||
username: my-user
|
||||
password: my-pass
|
||||
my-volume2:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
server: my-server2
|
||||
share: my-share2
|
||||
username: my-user2
|
||||
password: my-pass2
|
||||
asserts:
|
||||
- documentIndex: &pvDoc 1
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *pvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume1-1117390590
|
||||
- documentIndex: &otherPvDoc 4
|
||||
isKind:
|
||||
of: PersistentVolume
|
||||
- documentIndex: *otherPvDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-my-volume2-1335560034
|
||||
- documentIndex: &deploymentDoc 6
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: my-volume1
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-my-volume1-1117390590
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: my-volume2
|
||||
persistentVolumeClaim:
|
||||
claimName: release-name-common-test-my-volume2-1335560034
|
||||
@@ -2,7 +2,7 @@ apiVersion: v2
|
||||
name: common
|
||||
description: A library chart for iX Official Catalog
|
||||
type: library
|
||||
version: 1.0.12
|
||||
version: 1.1.0
|
||||
appVersion: v1
|
||||
annotations:
|
||||
title: Common Library Chart
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
# Persistence
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------------------------------------------------------ | :-------: | :------: | :-----------: | :----------------------------------------------: | :---------------------------------------------------------------------------------- |
|
||||
| persistence | `dict` | ❌ | ❌ | `{}` | Define the persistence as dicts |
|
||||
| persistence.[volume-name] | `dict` | ✅ | ❌ | `{}` | Holds persistence definition |
|
||||
| persistence.[volume-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the persistence |
|
||||
| persistence.[volume-name].type | `string` | ❌ | ❌ | `{{ .Values.fallbackDefaults.persistenceType }}` | Define the persistence type (ixVolume, hostPath, configmap, secret, device) |
|
||||
| persistence.[volume-name].mountPath | `string` | ✅ | ✅ | `""` | Default mountPath for all containers that are selected |
|
||||
| persistence.[volume-name].mountPropagation | `string` | ❌ | ✅ | `""` | Default mountPropagation for all containers that are selected |
|
||||
| persistence.[volume-name].subPath | `string` | ❌ | ✅ | `""` | Default subPath for all containers that are selected |
|
||||
| persistence.[volume-name].readOnly | `boolean` | ❌ | ❌ | `false` | Default readOnly for all containers that are selected |
|
||||
| persistence.[volume-name].targetSelectAll | `boolean` | ❌ | ❌ | `false` | Define wether to define this volume to all workloads and mount it on all containers |
|
||||
| persistence.[volume-name].targetSelector | `dict` | ❌ | ❌ | `{}` | Define a dict with pod and containers to mount |
|
||||
| persistence.[volume-name].targetSelector.[pod-name] | `dict` | ❌ | ❌ | `{}` | Define a dict named after the pod to define the volume |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name] | `dict` | ❌ | ❌ | `{}` | Define a dict named after the container to mount the volume |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].mountPath | `string` | ❌ | ✅ | `[volume-name].mountPath` | Define the mountPath for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].mountPropagation | `string` | ❌ | ✅ | `[volume-name].mountPropagation` | Define the mountPropagation for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].subPath | `string` | ❌ | ✅ | `[volume-name].subPath` | Define the subPath for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].readOnly | `boolean` | ❌ | ❌ | `[volume-name].readOnly` | Define the readOnly for the container |
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------------------------------------------------------ | :-------: | :------: | :-----------: | :----------------------------------------------: | :------------------------------------------------------------------------------------------------------------------- |
|
||||
| persistence | `dict` | ❌ | ❌ | `{}` | Define the persistence as dicts |
|
||||
| persistence.[volume-name] | `dict` | ✅ | ❌ | `{}` | Holds persistence definition |
|
||||
| persistence.[volume-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the persistence |
|
||||
| persistence.[volume-name].type | `string` | ❌ | ❌ | `{{ .Values.fallbackDefaults.persistenceType }}` | Define the persistence type (ixVolume, hostPath, configmap, secret, device, pvc, ix-zfs-pvc, smb-pv-pvc, nfs-pv-pvc) |
|
||||
| persistence.[volume-name].mountPath | `string` | ✅ | ✅ | `""` | Default mountPath for all containers that are selected |
|
||||
| persistence.[volume-name].mountPropagation | `string` | ❌ | ✅ | `""` | Default mountPropagation for all containers that are selected |
|
||||
| persistence.[volume-name].subPath | `string` | ❌ | ✅ | `""` | Default subPath for all containers that are selected |
|
||||
| persistence.[volume-name].readOnly | `boolean` | ❌ | ❌ | `false` | Default readOnly for all containers that are selected |
|
||||
| persistence.[volume-name].targetSelectAll | `boolean` | ❌ | ❌ | `false` | Define wether to define this volume to all workloads and mount it on all containers |
|
||||
| persistence.[volume-name].targetSelector | `dict` | ❌ | ❌ | `{}` | Define a dict with pod and containers to mount |
|
||||
| persistence.[volume-name].targetSelector.[pod-name] | `dict` | ❌ | ❌ | `{}` | Define a dict named after the pod to define the volume |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name] | `dict` | ❌ | ❌ | `{}` | Define a dict named after the container to mount the volume |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].mountPath | `string` | ❌ | ✅ | `[volume-name].mountPath` | Define the mountPath for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].mountPropagation | `string` | ❌ | ✅ | `[volume-name].mountPropagation` | Define the mountPropagation for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].subPath | `string` | ❌ | ✅ | `[volume-name].subPath` | Define the subPath for the container |
|
||||
| persistence.[volume-name].targetSelector.[pod-name].[container-name].readOnly | `boolean` | ❌ | ❌ | `[volume-name].readOnly` | Define the readOnly for the container |
|
||||
|
||||
> When `targetSelectAll` is `true`, it will define the volume to all pods and volumeMount to all containers (`targetSelector` is ignored in this case)
|
||||
> When `targetSelector` is defined, it will define the volume to the pod(s) and volumeMount to the container(s) selected. See below for the selector structure.
|
||||
@@ -48,6 +48,10 @@ Naming scheme:
|
||||
- [hostPath](hostPath.md)
|
||||
- [device](device.md)
|
||||
- [secret](secret.md)
|
||||
- [pvc](pvc.md)
|
||||
- [ix-zfs-pvc](ix-zfs-pvc.md)
|
||||
- [smb-pv-pvc](smb-pv-pvc.md)
|
||||
- [nfs-pv-pvc](nfs-pv-pvc.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
41
library/common/docs/persistence/ix-zfs-pvc.md
Normal file
41
library/common/docs/persistence/ix-zfs-pvc.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ix-zfs-pvc
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------ | :-----------: | :------: | :----------------: | :----------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| persistence.[volume-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for persistence |
|
||||
| persistence.[volume-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for persistence |
|
||||
| persistence.[volume-name].retain | `boolean` | ❌ | ❌ | `{{ .Values.global.fallbackDefaults.pvcRetain }}` | Define wether the to add helm annotation to retain resource on uninstall (Middleware should also retain it when deleting the NS) |
|
||||
| persistence.[volume-name].accessModes | `string/list` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcAccessModes }}` | Define the accessModes of the PVC, if it's single can be defined as a string, multiple as a list |
|
||||
| persistence.[volume-name].size | `string` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcSize }}` | Define the size of the PVC |
|
||||
|
||||
> This type can only be used within TrueNAS SCALE
|
||||
> It will use the storage class name injected by the middleware
|
||||
|
||||
---
|
||||
|
||||
Notes:
|
||||
|
||||
View common `keys` of `persistence` in [Persistence Documentation](README.md).
|
||||
|
||||
---
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: ix-zfs-pvc
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
annotation1: value1
|
||||
accessModes: ReadWriteOnce
|
||||
retain: false
|
||||
size: 2Gi
|
||||
# targetSelectAll: true
|
||||
targetSelector:
|
||||
pod-name:
|
||||
container-name:
|
||||
mountPath: /path/to/mount
|
||||
```
|
||||
50
library/common/docs/persistence/nfs-pv-pvc.md
Normal file
50
library/common/docs/persistence/nfs-pv-pvc.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# nfs-pv-pvc
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :--------------------------------------------- | :-----------: | :------: | :----------------: | :----------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| persistence.[volume-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for persistence |
|
||||
| persistence.[volume-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for persistence |
|
||||
| persistence.[volume-name].retain | `boolean` | ❌ | ❌ | `{{ .Values.global.fallbackDefaults.pvcRetain }}` | Define wether the to add helm annotation to retain resource on uninstall (Middleware should also retain it when deleting the NS) |
|
||||
| persistence.[volume-name].accessModes | `string/list` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcAccessModes }}` | Define the accessModes of the PVC, if it's single can be defined as a string, multiple as a list |
|
||||
| persistence.[volume-name].size | `string` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcSize }}` | Define the size of the PVC |
|
||||
| persistence.[volume-name].server | `string` | ✅ | ✅ | `""` | Define NFS Server |
|
||||
| persistence.[volume-name].share | `string` | ✅ | ✅ | `""` | Define NFS Share (Must start with `/`) |
|
||||
| persistence.[volume-name].mountOptions | `list` | ❌ | ✅ | `[]` | Define mount options for the CSI |
|
||||
| persistence.[volume-name].mountOptions[].key | `string` | ✅ | ✅ | `[]` | Define key of mount option for the CSI |
|
||||
| persistence.[volume-name].mountOptions[].value | `string` | ❌ | ✅ | `[]` | Define value of mount option for the CSI |
|
||||
|
||||
---
|
||||
|
||||
Notes:
|
||||
|
||||
View common `keys` of `persistence` in [Persistence Documentation](README.md).
|
||||
|
||||
---
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: nfs-pv-pvc
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
annotation1: value1
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
retain: false
|
||||
size: 2Gi
|
||||
server: my-server.mydomain.local
|
||||
share: /my-share
|
||||
mountOptions:
|
||||
- key: nfsvers
|
||||
value: "4.1"
|
||||
- key: nolock
|
||||
# targetSelectAll: true
|
||||
targetSelector:
|
||||
pod-name:
|
||||
container-name:
|
||||
mountPath: /path/to/mount
|
||||
```
|
||||
50
library/common/docs/persistence/pvc.md
Normal file
50
library/common/docs/persistence/pvc.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# pvc
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :----------------------------------------- | :-----------: | :------: | :----------------: | :----------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| persistence.[volume-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for persistence |
|
||||
| persistence.[volume-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for persistence |
|
||||
| persistence.[volume-name].retain | `boolean` | ❌ | ❌ | `{{ .Values.global.fallbackDefaults.pvcRetain }}` | Define wether the to add helm annotation to retain resource on uninstall (Middleware should also retain it when deleting the NS) |
|
||||
| persistence.[volume-name].accessModes | `string/list` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcAccessModes }}` | Define the accessModes of the PVC, if it's single can be defined as a string, multiple as a list |
|
||||
| persistence.[volume-name].volumeName | `string` | ❌ | ✅ | | Define the volumeName of a PV, backing the claim |
|
||||
| persistence.[volume-name].existingClaim | `string` | ❌ | ✅ | | Define an existing claim to use |
|
||||
| persistence.[volume-name].storageClassName | `string` | ❌ | ✅ | See below | Define an existing claim to use |
|
||||
| persistence.[volume-name].size | `string` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcSize }}` | Define the size of the PVC |
|
||||
|
||||
> - If storageClass is defined on the `persistence`:
|
||||
> - "-"
|
||||
> - Returns `""`, which means requesting a PV without class
|
||||
> - Else
|
||||
> - Return the original defined `storageClass`
|
||||
> - Else if there is a storageClass defined in `{{ .Values.fallbackDefaults.storageClass }}`, return this
|
||||
|
||||
---
|
||||
|
||||
Notes:
|
||||
|
||||
View common `keys` of `persistence` in [Persistence Documentation](README.md).
|
||||
|
||||
---
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: pvc
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
annotation1: value1
|
||||
accessModes: ReadWriteOnce
|
||||
volumeName: volume-name-backing-the-pvc
|
||||
existingClaim: existing-claim-name
|
||||
retain: true
|
||||
size: 2Gi
|
||||
# targetSelectAll: true
|
||||
targetSelector:
|
||||
pod-name:
|
||||
container-name:
|
||||
mountPath: /path/to/mount
|
||||
```
|
||||
56
library/common/docs/persistence/smb-pv-pvc.md
Normal file
56
library/common/docs/persistence/smb-pv-pvc.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# smb-pv-pvc
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :--------------------------------------------- | :-----------: | :------: | :----------------: | :----------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| persistence.[volume-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for persistence |
|
||||
| persistence.[volume-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for persistence |
|
||||
| persistence.[volume-name].retain | `boolean` | ❌ | ❌ | `{{ .Values.global.fallbackDefaults.pvcRetain }}` | Define wether the to add helm annotation to retain resource on uninstall (Middleware should also retain it when deleting the NS) |
|
||||
| persistence.[volume-name].accessModes | `string/list` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcAccessModes }}` | Define the accessModes of the PVC, if it's single can be defined as a string, multiple as a list |
|
||||
| persistence.[volume-name].size | `string` | ❌ | ✅ | `{{ .Values.global.fallbackDefaults.pvcSize }}` | Define the size of the PVC |
|
||||
| persistence.[volume-name].server | `string` | ✅ | ✅ | `""` | Define SMB Server |
|
||||
| persistence.[volume-name].share | `string` | ✅ | ✅ | `""` | Define SMB Share |
|
||||
| persistence.[volume-name].username | `string` | ✅ | ✅ | `""` | Define SMB Username |
|
||||
| persistence.[volume-name].password | `string` | ✅ | ✅ | `""` | Define SMB Password |
|
||||
| persistence.[volume-name].mountOptions | `list` | ❌ | ✅ | `[]` | Define mount options for the CSI |
|
||||
| persistence.[volume-name].mountOptions[].key | `string` | ✅ | ✅ | `[]` | Define key of mount option for the CSI |
|
||||
| persistence.[volume-name].mountOptions[].value | `string` | ❌ | ✅ | `[]` | Define value of mount option for the CSI |
|
||||
|
||||
---
|
||||
|
||||
Notes:
|
||||
|
||||
View common `keys` of `persistence` in [Persistence Documentation](README.md).
|
||||
|
||||
---
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
persistence:
|
||||
pvc-vol:
|
||||
enabled: true
|
||||
type: smb-pv-pvc
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
annotation1: value1
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
retain: false
|
||||
size: 2Gi
|
||||
server: my-server.mydomain.local
|
||||
share: my-share
|
||||
username: my-username
|
||||
password: my-password
|
||||
mountOptions:
|
||||
- key: vers
|
||||
value: "3.0"
|
||||
- key: dir_mode
|
||||
value: "0777"
|
||||
- key: noperm
|
||||
# targetSelectAll: true
|
||||
targetSelector:
|
||||
pod-name:
|
||||
container-name:
|
||||
mountPath: /path/to/mount
|
||||
```
|
||||
73
library/common/templates/class/_persistentVolume.tpl
Normal file
73
library/common/templates/class/_persistentVolume.tpl
Normal file
@@ -0,0 +1,73 @@
|
||||
{{/* PersistentVolume Class */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.class.pv" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
name: The name of the PV.
|
||||
labels: The labels of the PV.
|
||||
annotations: The annotations of the PV.
|
||||
provisioner: The provisioner to use for the PersistentVolume.
|
||||
driver: The driver to use for the csi
|
||||
retain: Whether to retain the PV after deletion. (Default: false)
|
||||
size: The size of the PersistentVolume. (Default: 1Gi)
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.class.pv" -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $retain := $rootCtx.Values.fallbackDefaults.pvcRetain -}}
|
||||
{{- if (kindIs "bool" $objectData.retain) -}}
|
||||
{{- $retain = $objectData.retain -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $reclaimPolicy := ternary "Retain" "Delete" $retain -}}
|
||||
|
||||
{{- $pvcSize := $rootCtx.Values.fallbackDefaults.pvcSize -}}
|
||||
{{- with $objectData.size -}}
|
||||
{{- $pvcSize = tpl . $rootCtx -}}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: {{ $objectData.name }}
|
||||
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- if $retain -}}
|
||||
{{- $_ := set $annotations "\"helm.sh/resource-policy\"" "keep" -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $annotations "pv.kubernetes.io/provisioned-by" $objectData.provisioner -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
capacity:
|
||||
storage: {{ $pvcSize }}
|
||||
persistentVolumeReclaimPolicy: {{ $reclaimPolicy }}
|
||||
storageClassName: {{ $objectData.name }}
|
||||
accessModes:
|
||||
{{- include "ix.v1.common.lib.pvc.accessModes" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Persistent Volume") | trim | nindent 4 -}}
|
||||
{{- if $objectData.mountOptions }}
|
||||
mountOptions:
|
||||
{{- range $opt := $objectData.mountOptions -}}
|
||||
{{- if $opt.value }}
|
||||
- {{ printf "%s=%s" (tpl $opt.key $rootCtx) (tpl (include "ix.v1.common.helper.makeIntOrNoop" $opt.value) $rootCtx) }}
|
||||
{{- else }}
|
||||
- {{ tpl $opt.key $rootCtx }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if eq "smb-pv-pvc" $objectData.type -}}
|
||||
{{- include "ix.v1.common.lib.storage.smbCSI" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
||||
{{- else if eq "nfs-pv-pvc" $objectData.type -}}
|
||||
{{- include "ix.v1.common.lib.storage.nfsCSI" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
58
library/common/templates/class/_persistentVolumeClaim.tpl
Normal file
58
library/common/templates/class/_persistentVolumeClaim.tpl
Normal file
@@ -0,0 +1,58 @@
|
||||
{{/* PersistentVolumeClaim Class */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.class.pvc" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
name: The name of the PVC.
|
||||
labels: The labels of the PVC.
|
||||
annotations: The annotations of the PVC.
|
||||
size: The size of the PVC. (Default: 1Gi)
|
||||
volumeName: The name of the volume to bind to. (Default: "")
|
||||
retain: Whether to retain the PVC after deletion. (Default: false)
|
||||
storageClass: The storage class to use. (Absent)
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.class.pvc" -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $pvcRetain := $rootCtx.Values.fallbackDefaults.pvcRetain -}}
|
||||
{{- if (kindIs "bool" $objectData.retain) -}}
|
||||
{{- $pvcRetain = $objectData.retain -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $pvcSize := $rootCtx.Values.fallbackDefaults.pvcSize -}}
|
||||
{{- with $objectData.size -}}
|
||||
{{- $pvcSize = tpl . $rootCtx -}}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ $objectData.name }}
|
||||
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- if $pvcRetain -}}
|
||||
{{- $_ := set $annotations "\"helm.sh/resource-policy\"" "keep" -}}
|
||||
{{- end -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- include "ix.v1.common.lib.pvc.accessModes" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Persistent Volume Claim") | trim | nindent 4 }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ $pvcSize }}
|
||||
{{- with $objectData.volumeName }}
|
||||
volumeName: {{ tpl . $rootCtx }}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.lib.storage.storageClassName" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Persistent Volume Claim") | trim | nindent 2 }}
|
||||
{{- end -}}
|
||||
@@ -15,7 +15,6 @@ objectData: The object data to be used to render the Pod.
|
||||
|
||||
{{- $_ := set $persistence "shortName" $name -}}
|
||||
{{- $_ := set $persistence "type" ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
|
||||
{{- include "ix.v1.common.lib.persistence.validation" (dict "rootCtx" $rootCtx "objectData" $persistence) -}}
|
||||
|
||||
{{- $selected := false -}}
|
||||
|
||||
@@ -53,6 +52,8 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- include "ix.v1.common.lib.pod.volume.emptyDir" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
|
||||
{{- else if eq "device" $type -}}
|
||||
{{- include "ix.v1.common.lib.pod.volume.device" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
|
||||
{{- else if (mustHas $type (list "smb-pv-pvc" "nfs-pv-pvc" "ix-zfs-pvc" "pvc")) -}}
|
||||
{{- include "ix.v1.common.lib.pod.volume.pvc" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
28
library/common/templates/lib/pod/volumes/_pvc.tpl
Normal file
28
library/common/templates/lib/pod/volumes/_pvc.tpl
Normal file
@@ -0,0 +1,28 @@
|
||||
{{/* Returns PVC Volume */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.pod.volume.pvc" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
rootCtx: The root context of the chart.
|
||||
objectData: The object data to be used to render the volume.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.pod.volume.pvc" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $pvcName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $rootCtx) $objectData.shortName) -}}
|
||||
{{- with $objectData.existingClaim -}}
|
||||
{{- $pvcName = tpl . $rootCtx -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if mustHas $objectData.type (list "nfs-pv-pvc" "smb-pv-pvc") -}}
|
||||
{{- $hashValues := (printf "%s-%s" $objectData.server $objectData.share) -}}
|
||||
{{- if $objectData.domain -}}
|
||||
{{- $hashValues = (printf "%s-%s" $hashValues $objectData.domain) -}}
|
||||
{{- end -}}
|
||||
{{/* Generate the unique claim name */}}
|
||||
{{- $hash := adler32sum $hashValues -}}
|
||||
{{- $pvcName = (printf "%s-%v" $pvcName $hash) -}}
|
||||
{{- end }}
|
||||
- name: {{ $objectData.shortName }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ $pvcName }}
|
||||
{{- end -}}
|
||||
32
library/common/templates/lib/storage/_accessModes.tpl
Normal file
32
library/common/templates/lib/storage/_accessModes.tpl
Normal file
@@ -0,0 +1,32 @@
|
||||
{{/* PVC - Access Modes */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.pvc.accessModes" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the chart.
|
||||
objectData: The object data of the pvc
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.lib.pvc.accessModes" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $caller := .caller -}}
|
||||
|
||||
{{- $accessModes := $objectData.accessModes -}}
|
||||
|
||||
{{- if kindIs "string" $accessModes -}}
|
||||
{{- $accessModes = (list $accessModes) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $accessModes -}}
|
||||
{{- $accessModes = $rootCtx.Values.fallbackDefaults.accessModes -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $validAccessModes := (list "ReadWriteOnce" "ReadOnlyMany" "ReadWriteMany" "ReadWriteOncePod") -}}
|
||||
|
||||
{{- range $accessModes -}}
|
||||
{{- $mode := tpl . $rootCtx -}}
|
||||
{{- if not (mustHas $mode $validAccessModes) -}}
|
||||
{{- fail (printf "%s - Expected <accessModes> entry to be one of [%s], but got [%s]" $caller (join ", " $validAccessModes) $mode) -}}
|
||||
{{- end }}
|
||||
- {{ $mode }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
21
library/common/templates/lib/storage/_nfsCSI.tpl
Normal file
21
library/common/templates/lib/storage/_nfsCSI.tpl
Normal file
@@ -0,0 +1,21 @@
|
||||
{{/* NFS CSI */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.storage.nfsCSI" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
driver: The name of the driver.
|
||||
server: The server address.
|
||||
share: The share to the NFS share.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.storage.nfsCSI" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
csi:
|
||||
driver: {{ $objectData.driver }}
|
||||
{{- /* Create a unique handle, server/share#release-app-volumeName */}}
|
||||
volumeHandle: {{ printf "%s%s#%s" $objectData.server $objectData.share $objectData.name }}
|
||||
volumeAttributes:
|
||||
server: {{ tpl $objectData.server $rootCtx }}
|
||||
share: {{ tpl $objectData.share $rootCtx }}
|
||||
{{- end -}}
|
||||
23
library/common/templates/lib/storage/_smbCSI.tpl
Normal file
23
library/common/templates/lib/storage/_smbCSI.tpl
Normal file
@@ -0,0 +1,23 @@
|
||||
{{/* SMB CSI */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.storage.smbCSI" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
driver: The name of the driver.
|
||||
server: The server address.
|
||||
share: The share to the SMB share.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.storage.smbCSI" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
csi:
|
||||
driver: {{ $objectData.driver }}
|
||||
{{- /* Create a unique handle, server/share#release-app-volumeName */}}
|
||||
volumeHandle: {{ printf "%s/%s#%s" $objectData.server $objectData.share $objectData.name }}
|
||||
volumeAttributes:
|
||||
source: {{ printf "//%v/%v" (tpl $objectData.server $rootCtx) (tpl $objectData.share $rootCtx) }}
|
||||
nodeStageSecretRef:
|
||||
name: {{ $objectData.name }}
|
||||
namespace: {{ $rootCtx.Release.Namespace }}
|
||||
{{- end -}}
|
||||
51
library/common/templates/lib/storage/_storageClassName.tpl
Normal file
51
library/common/templates/lib/storage/_storageClassName.tpl
Normal file
@@ -0,0 +1,51 @@
|
||||
{{/* PVC - Storage Class Name */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.storage.storageClassName" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the chart.
|
||||
objectData: The object data of the pvc
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.storage.storageClassName" -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $caller := .caller -}}
|
||||
|
||||
{{/*
|
||||
If type is "ix-zfs-pvc":
|
||||
Return the value set .Values.global.ixChartContext.storageClassName
|
||||
If storageClass is defined on the objectData:
|
||||
If the value is "-" (dash):
|
||||
Return ""
|
||||
Else:
|
||||
Return the original defined storageClass (smb-pv-pvc and nfs-pv-pvc will fall into this case)
|
||||
Else if there is a storageClass defined in .Values.fallbackDefaults.storageClass: (Default is "")
|
||||
Return this
|
||||
*/}}
|
||||
|
||||
{{- $className := "" -}}
|
||||
{{- if eq "ix-zfs-pvc" $objectData.type -}}
|
||||
{{- if not $rootCtx.Values.global.ixChartContext.storageClassName -}}
|
||||
{{- fail (printf "%s - Expected non-empty <global.ixChartContext.storageClassName> on [ix-zfs-pvc] type" $caller) -}}
|
||||
{{- end -}}
|
||||
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}
|
||||
|
||||
{{- else if $objectData.storageClass -}}
|
||||
{{- $className = (tpl $objectData.storageClass $rootCtx) -}}
|
||||
|
||||
{{- else if $rootCtx.Values.fallbackDefaults.storageClass -}} {{/* Probably useful in CI scenarios */}}
|
||||
{{- $className = tpl $rootCtx.Values.fallbackDefaults.storageClass $rootCtx -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Empty value on storageClasName key means no storageClass
|
||||
While absent storageClasName key means use the default storageClass
|
||||
Because helm strips "", we need to use "-" to represent empty value
|
||||
*/}}
|
||||
|
||||
{{- if $className -}}
|
||||
{{- if eq "-" $className }}
|
||||
storageClassName: ""
|
||||
{{- else }}
|
||||
storageClassName: {{ $className }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
50
library/common/templates/lib/storage/_validataionCsiNFS.tpl
Normal file
50
library/common/templates/lib/storage/_validataionCsiNFS.tpl
Normal file
@@ -0,0 +1,50 @@
|
||||
{{/* Validate NFS CSI */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.storage.nfsCSI.validation" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
driver: The name of the driver.
|
||||
mountOptions: The mount options.
|
||||
server: The server address.
|
||||
share: The share to the NFS share.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.storage.nfsCSI.validation" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if hasKey $rootCtx.Values.global "ixChartContext" -}}
|
||||
{{- if not $rootCtx.Values.global.ixChartContext.hasNFSCSI -}}
|
||||
{{- fail "NFS CSI - Not supported CSI" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $required := (list "server" "share") -}}
|
||||
{{- range $item := $required -}}
|
||||
{{- if not (get $objectData $item) -}}
|
||||
{{- fail (printf "NFS CSI - Expected <%v> to be non-empty" $item) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (hasPrefix "/" $objectData.share) -}}
|
||||
{{- fail "NFS CSI - Expected <share> to start with [/]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* TODO: Allow only specific opts / set specific opts by default? */}}
|
||||
{{- $validOpts := list -}}
|
||||
{{- range $opt := $objectData.mountOptions -}}
|
||||
{{- if not (kindIs "map" $opt) -}}
|
||||
{{- fail (printf "NFS CSI - Expected <mountOption> item to be a dict, but got [%s]" (kindOf $opt)) -}}
|
||||
{{- end -}}
|
||||
{{- if not $opt.key -}}
|
||||
{{- fail "NFS CSI - Expected key in <mountOptions> to be non-empty" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
{{- $key := tpl $opt.key $rootCtx -}}
|
||||
{{- if not (mustHas $key $validOpts) -}}
|
||||
{{- fail (printf "NFS CSI - Expected <mountOptions> to be one of [%v], but got [%v]" (join ", " $validOpts) $opt) -}}
|
||||
{{- end -}}
|
||||
*/}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
54
library/common/templates/lib/storage/_validataionCsiSMB.tpl
Normal file
54
library/common/templates/lib/storage/_validataionCsiSMB.tpl
Normal file
@@ -0,0 +1,54 @@
|
||||
{{/* Validate SMB CSI */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.storage.smbCSI.validation" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
driver: The name of the driver.
|
||||
mountOptions: The mount options.
|
||||
server: The server address.
|
||||
share: The share to the SMB share.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.storage.smbCSI.validation" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if hasKey $rootCtx.Values.global "ixChartContext" -}}
|
||||
{{- if not $rootCtx.Values.global.ixChartContext.hasSMBCSI -}}
|
||||
{{- fail "SMB CSI - Not supported CSI" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $required := (list "server" "share" "username" "password") -}}
|
||||
{{- range $item := $required -}}
|
||||
{{- if not (get $objectData $item) -}}
|
||||
{{- fail (printf "SMB CSI - Expected <%v> to be non-empty" $item) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if hasPrefix "//" $objectData.server -}}
|
||||
{{- fail "SMB CSI - Did not expect <server> to start with [//]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if hasPrefix "/" $objectData.share -}}
|
||||
{{- fail "SMB CSI - Did not expect <share> to start with [/]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* TODO: Allow only specific opts? / set specific opts by default? */}}
|
||||
{{- $validOpts := list -}}
|
||||
{{- range $opt := $objectData.mountOptions -}}
|
||||
{{- if not (kindIs "map" $opt) -}}
|
||||
{{- fail (printf "SMB CSI - Expected <mountOption> item to be a dict, but got [%s]" (kindOf $opt)) -}}
|
||||
{{- end -}}
|
||||
{{- if not $opt.key -}}
|
||||
{{- fail "SMB CSI - Expected key in <mountOptions> to be non-empty" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
{{- $key := tpl $opt.key $rootCtx -}}
|
||||
{{- if not (mustHas $key $validOpts) -}}
|
||||
{{- fail (printf "SMB CSI - Expected <mountOptions> to be one of [%v], but got [%v]" (join ", " $validOpts) $opt) -}}
|
||||
{{- end -}}
|
||||
*/}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -10,7 +10,7 @@ objectData:
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $types := (list "emptyDir" "hostPath" "ixVolume" "secret" "configmap" "device") -}}
|
||||
{{- $types := (list "smb-pv-pvc" "nfs-pv-pvc" "ix-zfs-pvc" "pvc" "emptyDir" "hostPath" "ixVolume" "secret" "configmap" "device") -}}
|
||||
{{- if not (mustHas $objectData.type $types) -}}
|
||||
{{- fail (printf "Persistence - Expected <type> to be one of [%s], but got [%s]" (join ", " $types) $objectData.type) -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -25,10 +25,14 @@
|
||||
{{/* Render External Interface(s) */}}
|
||||
{{- include "ix.v1.common.spawner.externalInterface" . | nindent 0 -}}
|
||||
|
||||
{{/* Render PVC(s) */}}
|
||||
{{- include "ix.v1.common.spawner.pvc" . | nindent 0 -}}
|
||||
|
||||
{{/* Render Workload(s) */}}
|
||||
{{- include "ix.v1.common.spawner.workload" . | nindent 0 -}}
|
||||
|
||||
{{/* Render Services(s) */}}
|
||||
{{- include "ix.v1.common.spawner.service" . | nindent 0 -}}
|
||||
|
||||
|
||||
{{- end -}}
|
||||
|
||||
93
library/common/templates/spawner/_pvc.tpl
Normal file
93
library/common/templates/spawner/_pvc.tpl
Normal file
@@ -0,0 +1,93 @@
|
||||
{{/* PVC Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.spawner.pvc" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.spawner.pvc" -}}
|
||||
|
||||
{{- range $name, $persistence := .Values.persistence -}}
|
||||
|
||||
{{- if $persistence.enabled -}}
|
||||
|
||||
{{/* Create a copy of the persistence */}}
|
||||
{{- $objectData := (mustDeepCopy $persistence) -}}
|
||||
|
||||
{{- $_ := set $objectData "type" ($objectData.type | default $.Values.fallbackDefaults.persistenceType) -}}
|
||||
|
||||
{{/* Perform general validations */}}
|
||||
{{- include "ix.v1.common.lib.persistence.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- include "ix.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Persistence") -}}
|
||||
|
||||
{{/*
|
||||
Naming scheme on pvc types:
|
||||
pvc creates a PVC with the default StorageClass (Useful for CI or testing on local cluster)
|
||||
ix-zfs-pvc creates a PVC and is dependent on iX values injection (eg StorageClass)
|
||||
smb-pv-pvc creates a PV and PVC (This still checks for iX values, but only when running in SCALE)
|
||||
nfs-pv-pvc creates a PV and PVC (This still checks for iX values, but only when running in SCALE)
|
||||
*/}}
|
||||
{{/* Only spawn PVC if its enabled and any type of "pvc" */}}
|
||||
{{- if and (mustHas $objectData.type (list "smb-pv-pvc" "nfs-pv-pvc" "ix-zfs-pvc" "pvc")) (not $objectData.existingClaim) -}}
|
||||
{{- $objectName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $) $name) -}}
|
||||
{{/* Perform validations */}}
|
||||
{{- include "ix.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{/* Set the name of the secret */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{- if eq $objectData.type "smb-pv-pvc" -}}
|
||||
{{/* Validate SMB CSI */}}
|
||||
{{- include "ix.v1.common.lib.storage.smbCSI.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- $hashValues := (printf "%s-%s" $objectData.server $objectData.share) -}}
|
||||
{{- if $objectData.domain -}}
|
||||
{{- $hashValues = (printf "%s-%s" $hashValues $objectData.domain) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Create a unique name taking into account server and share,
|
||||
without this, changing one of those values is not possible */}}
|
||||
{{- $hash := adler32sum $hashValues -}}
|
||||
{{- $_ := set $objectData "name" (printf "%s-%v" $objectName $hash) -}}
|
||||
|
||||
{{- $_ := set $objectData "provisioner" "smb.csi.k8s.io" -}}
|
||||
{{- $_ := set $objectData "driver" "smb.csi.k8s.io" -}}
|
||||
{{- $_ := set $objectData "storageClass" $objectData.name -}}
|
||||
|
||||
{{/* Create secret with creds */}}
|
||||
{{- $secretData := (dict
|
||||
"name" $objectData.name
|
||||
"labels" ($objectData.labels | default dict)
|
||||
"annotations" ($objectData.annotations | default dict)
|
||||
"data" (dict "username" $objectData.username "password" $objectData.password)
|
||||
) -}}
|
||||
{{- with $objectData.domain -}}
|
||||
{{- $_ := set $secretData.data "domain" . -}}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.class.secret" (dict "rootCtx" $ "objectData" $secretData) -}}
|
||||
|
||||
{{/* Create the PV */}}
|
||||
{{- include "ix.v1.common.class.pv" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- else if eq $objectData.type "nfs-pv-pvc" -}}
|
||||
{{/* Validate NFS CSI */}}
|
||||
{{- include "ix.v1.common.lib.storage.nfsCSI.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- $hashValues := (printf "%s-%s" $objectData.server $objectData.share) -}}
|
||||
{{/* Create a unique name taking into account server and share,
|
||||
without this, changing one of those values is not possible */}}
|
||||
{{- $hash := adler32sum $hashValues -}}
|
||||
{{- $_ := set $objectData "name" (printf "%s-%v" $objectName $hash) -}}
|
||||
|
||||
{{- $_ := set $objectData "provisioner" "nfs.csi.k8s.io" -}}
|
||||
{{- $_ := set $objectData "driver" "nfs.csi.k8s.io" -}}
|
||||
{{- $_ := set $objectData "storageClass" $objectData.name -}}
|
||||
|
||||
{{/* Create the PV */}}
|
||||
{{- include "ix.v1.common.class.pv" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "ix.v1.common.class.pvc" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -9,7 +9,12 @@ fallbackDefaults:
|
||||
probeType: http
|
||||
serviceProtocol: tcp
|
||||
serviceType: ClusterIP
|
||||
persistenceType: emptyDir # TODO: Maybe something else?
|
||||
persistenceType: emptyDir
|
||||
pvcRetain: false
|
||||
pvcSize: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClass: ""
|
||||
probeTimeouts:
|
||||
liveness:
|
||||
initialDelaySeconds: 10
|
||||
|
||||
Reference in New Issue
Block a user