diff --git a/library/common-test/tests/persistence/pvc_data_test.yaml b/library/common-test/tests/persistence/pvc_data_test.yaml index b8864a6a27..40db3907ff 100644 --- a/library/common-test/tests/persistence/pvc_data_test.yaml +++ b/library/common-test/tests/persistence/pvc_data_test.yaml @@ -35,6 +35,17 @@ tests: 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 diff --git a/library/common/1.0.0/templates/spawner/_pvc.tpl b/library/common/1.0.0/templates/spawner/_pvc.tpl index ee74c2c0e2..e6344b194d 100644 --- a/library/common/1.0.0/templates/spawner/_pvc.tpl +++ b/library/common/1.0.0/templates/spawner/_pvc.tpl @@ -18,7 +18,7 @@ {{- include "ix.v1.common.lib.persistence.validation" (dict "rootCtx" $ "objectData" $objectData) -}} {{/* Only spawn PVC if it's enabled and type of "pvc" */}} - {{- if eq "pvc" $objectData.type -}} + {{- if and (eq "pvc" $objectData.type) (not $objectData.existingClaim) -}} {{- $objectName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $) $name) -}} {{/* Perform validations */}}