Skip to content

Commit d8768ba

Browse files
authored
Add ability to configure StatefulSet PVC retention policy (#517)
Signed-off-by: Sam McBroom <[email protected]>
1 parent 7caefcc commit d8768ba

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [CHANGE] Updated default `align_queries_with_step` to **false** to match documentation #513
66
* [ENHANCEMENT] Add `nginx.config.upstream_protocol` field to configure the upstream protocol in the nginx configuration #506
7+
* [ENHANCEMENT] Add ability to set `persistentVolumeClaimRetentionPolicy` on alertmanager, ingester, compactor, and store-gateway StatefulSets #517
78
* [BUGFIX] fix: upstream_protocol reference in auth_orgs #509
89
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.18.1 #510
910

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Kubernetes: `^1.19.0-0`
113113
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;accessModes | list | `["ReadWriteOnce"]` | Alertmanager data Persistent Volume access modes Must match those of existing PV or dynamic provisioner Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ |
114114
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;annotations | object | `{}` | Alertmanager data Persistent Volume Claim annotations |
115115
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;enabled | bool | `true` | If true and alertmanager.statefulSet.enabled is true, Alertmanager will create/use a Persistent Volume Claim If false, use emptyDir |
116+
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;retentionPolicy | object | `{}` | StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
116117
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Alertmanager data Persistent Volume size |
117118
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Alertmanager data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
118119
| alertmanager.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Alertmanager data Persistent Volume to mount Useful if the volume's root directory is not empty |
@@ -184,6 +185,7 @@ Kubernetes: `^1.19.0-0`
184185
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;accessModes | list | `["ReadWriteOnce"]` | compactor data Persistent Volume access modes Must match those of existing PV or dynamic provisioner Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ |
185186
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;annotations | object | `{}` | compactor data Persistent Volume Claim annotations |
186187
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;enabled | bool | `true` | If true compactor will create/use a Persistent Volume Claim If false, use emptyDir |
188+
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;retentionPolicy | object | `{}` | StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
187189
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | |
188190
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | compactor data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
189191
| compactor.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of compactor data Persistent Volume to mount Useful if the volume's root directory is not empty |
@@ -346,6 +348,7 @@ Kubernetes: `^1.19.0-0`
346348
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;accessModes | list | `["ReadWriteOnce"]` | Ingester data Persistent Volume access modes Must match those of existing PV or dynamic provisioner Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ |
347349
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;annotations | object | `{}` | Ingester data Persistent Volume Claim annotations |
348350
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;enabled | bool | `true` | If true and ingester.statefulSet.enabled is true, Ingester will create/use a Persistent Volume Claim If false, use emptyDir |
351+
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;retentionPolicy | object | `{}` | StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
349352
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Ingester data Persistent Volume size |
350353
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Ingester data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
351354
| ingester.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Ingester data Persistent Volume to mount Useful if the volume's root directory is not empty |
@@ -815,6 +818,7 @@ Kubernetes: `^1.19.0-0`
815818
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;accessModes | list | `["ReadWriteOnce"]` | Store-gateway data Persistent Volume access modes Must match those of existing PV or dynamic provisioner Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ |
816819
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;annotations | object | `{}` | Store-gateway data Persistent Volume Claim annotations |
817820
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;enabled | bool | `true` | If true Store-gateway will create/use a Persistent Volume Claim If false, use emptyDir |
821+
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;retentionPolicy | object | `{}` | StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
818822
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;size | string | `"2Gi"` | Store-gateway data Persistent Volume size |
819823
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;storageClass | string | `nil` | Store-gateway data Persistent Volume Storage Class If defined, storageClassName: <storageClass> If set to "-", storageClassName: "", which disables dynamic provisioning If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
820824
| store_gateway.&ZeroWidthSpace;persistentVolume.&ZeroWidthSpace;subPath | string | `""` | Subdirectory of Store-gateway data Persistent Volume to mount Useful if the volume's root directory is not empty |

templates/alertmanager/alertmanager-statefulset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ spec:
2121
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
2222
serviceName: {{ template "cortex.fullname" . }}-alertmanager-headless
2323
{{- if .Values.alertmanager.persistentVolume.enabled }}
24+
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }}
25+
{{- with .Values.alertmanager.persistentVolume.retentionPolicy }}
26+
persistentVolumeClaimRetentionPolicy:
27+
{{- toYaml . | nindent 4 }}
28+
{{- end }}
29+
{{- end }}
2430
volumeClaimTemplates:
2531
- metadata:
2632
name: storage

templates/compactor/compactor-statefulset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ spec:
1818
{{- toYaml .Values.compactor.strategy | nindent 4 }}
1919
serviceName: {{ template "cortex.fullname" . }}-compactor
2020
{{- if .Values.compactor.persistentVolume.enabled }}
21+
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }}
22+
{{- with .Values.compactor.persistentVolume.retentionPolicy }}
23+
persistentVolumeClaimRetentionPolicy:
24+
{{- toYaml . | nindent 4 }}
25+
{{- end }}
26+
{{- end }}
2127
volumeClaimTemplates:
2228
- metadata:
2329
name: storage

templates/ingester/ingester-statefulset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ spec:
2121
podManagementPolicy: "{{ .Values.ingester.statefulSet.podManagementPolicy }}"
2222
serviceName: {{ template "cortex.fullname" . }}-ingester-headless
2323
{{- if .Values.ingester.persistentVolume.enabled }}
24+
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }}
25+
{{- with .Values.ingester.persistentVolume.retentionPolicy }}
26+
persistentVolumeClaimRetentionPolicy:
27+
{{- toYaml . | nindent 4 }}
28+
{{- end }}
29+
{{- end }}
2430
volumeClaimTemplates:
2531
- metadata:
2632
name: storage

templates/store-gateway/store-gateway-statefulset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ spec:
2121
podManagementPolicy: {{ .Values.store_gateway.podManagementPolicy | quote }}
2222
serviceName: {{ template "cortex.fullname" . }}-store-gateway-headless
2323
{{- if .Values.store_gateway.persistentVolume.enabled }}
24+
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }}
25+
{{- with .Values.store_gateway.persistentVolume.retentionPolicy }}
26+
persistentVolumeClaimRetentionPolicy:
27+
{{- toYaml . | nindent 4 }}
28+
{{- end }}
29+
{{- end }}
2430
volumeClaimTemplates:
2531
- metadata:
2632
name: storage

values.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ alertmanager:
217217
# set, choosing the default provisioner.
218218
storageClass: null
219219

220+
# -- StatefulSetAutoDeletePVC feature
221+
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
222+
retentionPolicy: {}
223+
# whenDeleted: Retain
224+
# whenScaled: Retain
225+
220226
startupProbe:
221227
httpGet:
222228
path: /ready
@@ -543,6 +549,12 @@ ingester:
543549
# set, choosing the default provisioner.
544550
storageClass: null
545551

552+
# -- StatefulSetAutoDeletePVC feature
553+
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
554+
retentionPolicy: {}
555+
# whenDeleted: Retain
556+
# whenScaled: Retain
557+
546558
# -- Startup/liveness probes for ingesters are not recommended.
547559
# Ref: https://cortexmetrics.io/docs/guides/running-cortex-on-kubernetes/#take-extra-care-with-ingesters
548560
startupProbe: {}
@@ -1404,6 +1416,12 @@ store_gateway:
14041416
# set, choosing the default provisioner.
14051417
storageClass: null
14061418

1419+
# -- StatefulSetAutoDeletePVC feature
1420+
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
1421+
retentionPolicy: {}
1422+
# whenDeleted: Retain
1423+
# whenScaled: Retain
1424+
14071425
startupProbe:
14081426
failureThreshold: 60
14091427
initialDelaySeconds: 120
@@ -1520,6 +1538,12 @@ compactor:
15201538
# set, choosing the default provisioner.
15211539
storageClass: null
15221540

1541+
# -- StatefulSetAutoDeletePVC feature
1542+
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
1543+
retentionPolicy: {}
1544+
# whenDeleted: Retain
1545+
# whenScaled: Retain
1546+
15231547
startupProbe:
15241548
failureThreshold: 60
15251549
initialDelaySeconds: 120

0 commit comments

Comments
 (0)