diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 715e1469..f4335f31 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -20,6 +20,9 @@ annotations: - kind: added description: |- Added `stdin` and `tty` fields to container spec. + - kind: added + description: |- + Added `persistentVolumeClaimRetentionPolicy` field to statefulset spec. - kind: fixed description: |- Added `externalName` field to service schema. diff --git a/charts/library/common/schemas/controllers.json b/charts/library/common/schemas/controllers.json index b792b8ad..73c67899 100644 --- a/charts/library/common/schemas/controllers.json +++ b/charts/library/common/schemas/controllers.json @@ -146,6 +146,22 @@ "podManagementPolicy": { "type": "string" }, + "persistentVolumeClaimRetentionPolicy": { + "type": "object", + "additionalProperties": false, + "properties": { + "whenDeleted": { + "type": "string", + "enum": ["Delete", "Retain"], + "default": "Retain" + }, + "whenScaled": { + "type": "string", + "enum": ["Delete", "Retain"], + "default": "Retain" + } + } + }, "volumeClaimTemplates": { "type": "array", "items": { diff --git a/charts/library/common/templates/classes/_statefulset.tpl b/charts/library/common/templates/classes/_statefulset.tpl index 70679555..24a309da 100644 --- a/charts/library/common/templates/classes/_statefulset.tpl +++ b/charts/library/common/templates/classes/_statefulset.tpl @@ -47,6 +47,9 @@ spec: app.kubernetes.io/component: {{ $statefulsetObject.identifier }} {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }} + {{- with (dig "statefulset" "persistentVolumeClaimRetentionPolicy" nil $statefulsetObject) }} + persistentVolumeClaimRetentionPolicy: {{ . | nindent 4 }} + {{- end -}} template: metadata: {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $statefulsetObject)) }}