Skip to content

Commit

Permalink
[prometheus] Add support for PVC retention policy in statefulset (pro…
Browse files Browse the repository at this point in the history
…metheus-community#3748)

* Add support for statefulset PVC retention policy

* Introduce fields statefulSet.pvcDeleteOnStsDelete and
  statefulSet.pvcDeleteOnStsScale (bool) to delete or retain PVCs on
  deleting and scaling the statefulset (default is false).

Signed-off-by: zeritti <[email protected]>

* Bump chart version

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: zeritti <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
2 people authored and Matiasmct committed Mar 20, 2024
1 parent 391c9fd commit c78c55c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: prometheus
appVersion: v2.46.0
version: 24.2.0
version: 24.3.0
kubeVersion: ">=1.19.0-0"
description: Prometheus is a monitoring system and time series database.
home: https://prometheus.io/
Expand Down
5 changes: 5 additions & 0 deletions charts/prometheus/templates/sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ metadata:
name: {{ template "prometheus.server.fullname" . }}
namespace: {{ include "prometheus.namespace" . }}
spec:
{{- if semverCompare ">= 1.27.x" (include "prometheus.kubeVersion" .) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ ternary "Delete" "Retain" .Values.server.statefulSet.pvcDeleteOnStsDelete }}
whenScaled: {{ ternary "Delete" "Retain" .Values.server.statefulSet.pvcDeleteOnStsScale }}
{{- end }}
serviceName: {{ template "prometheus.server.fullname" . }}-headless
selector:
matchLabels:
Expand Down
15 changes: 15 additions & 0 deletions charts/prometheus/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"extraVolumeDirs": {
"type": "array"
},
"extraVolumeMounts": {
"type": "array"
},
"image": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -439,6 +442,9 @@
"readinessProbeTimeout": {
"type": "integer"
},
"releaseNamespace": {
"type": "boolean"
},
"remoteRead": {
"type": "array"
},
Expand All @@ -454,6 +460,9 @@
"retention": {
"type": "string"
},
"revisionHistoryLimit": {
"type": "integer"
},
"securityContext": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -590,6 +599,12 @@
},
"podManagementPolicy": {
"type": "string"
},
"pvcDeleteOnStsDelete": {
"type": "boolean"
},
"pvcDeleteOnStsScale": {
"type": "boolean"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ server:
servicePort: 10901
# nodePort: 10901

## Statefulset's persistent volume claim retention policy
## pvcDeleteOnStsDelete and pvcDeleteOnStsScale determine whether
## statefulset's PVCs are deleted (true) or retained (false) on scaling down
## and deleting statefulset, respectively. Requires 1.27.0+.
## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
##
pvcDeleteOnStsDelete: false
pvcDeleteOnStsScale: false

## Prometheus server readiness and liveness probe initial delay and timeout
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
##
Expand Down

0 comments on commit c78c55c

Please sign in to comment.