From 5fb72726997a01678e7ac4a634ee3f0f0006c044 Mon Sep 17 00:00:00 2001 From: peterabarr <90917602+peterabarr@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:01:00 +0100 Subject: [PATCH] [alertmanager] Add support for PVC retention policy in statefulset Fix Fix PVC policy Fix fmt Signed-off-by: peterabarr <90917602+peterabarr@users.noreply.github.com> --- charts/alertmanager/Chart.yaml | 2 +- .../alertmanager/templates/statefulset.yaml | 5 +++ charts/alertmanager/values.schema.json | 42 ++++++++++++++++++- charts/alertmanager/values.yaml | 10 +++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/charts/alertmanager/Chart.yaml b/charts/alertmanager/Chart.yaml index 4b0884111b8d..842cae8d7d01 100644 --- a/charts/alertmanager/Chart.yaml +++ b/charts/alertmanager/Chart.yaml @@ -6,7 +6,7 @@ icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/a sources: - https://github.com/prometheus/alertmanager type: application -version: 1.7.0 +version: 1.8.0 appVersion: v0.26.0 kubeVersion: ">=1.19.0-0" keywords: diff --git a/charts/alertmanager/templates/statefulset.yaml b/charts/alertmanager/templates/statefulset.yaml index 25d81a921345..98cd36208653 100644 --- a/charts/alertmanager/templates/statefulset.yaml +++ b/charts/alertmanager/templates/statefulset.yaml @@ -11,6 +11,11 @@ metadata: {{- end }} namespace: {{ include "alertmanager.namespace" . }} spec: + {{- if semverCompare ">= 1.27.x" (include "alertmanager.kubeVersion" .) }} + persistentVolumeClaimRetentionPolicy: + whenDeleted: {{ ternary "Delete" "Retain" .Values.server.statefulSet.pvcDeleteOnStsDelete }} + whenScaled: {{ ternary "Delete" "Retain" .Values.server.statefulSet.pvcDeleteOnStsScale }} + {{- end }} replicas: {{ .Values.replicaCount }} revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} selector: diff --git a/charts/alertmanager/values.schema.json b/charts/alertmanager/values.schema.json index 172dbcf3e67b..aa030c5917e7 100644 --- a/charts/alertmanager/values.schema.json +++ b/charts/alertmanager/values.schema.json @@ -747,7 +747,48 @@ "properties": { "annotations": { "type": "object" + }, + "enabled": { + "type": "boolean" + }, + "headless": { + "type": "object", + "properties": { + "annotations": { + "type": "object" + }, + "gRPC": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "servicePort": { + "type": "integer" + } + } + }, + "labels": { + "type": "object" + }, + "servicePort": { + "type": "integer" + } + } + }, + "labels": { + "type": "object" + }, + "podManagementPolicy": { + "type": "string" + }, + "pvcDeleteOnStsDelete": { + "type": "boolean" + }, + "pvcDeleteOnStsScale": { + "type": "boolean" } + } } }, "podAnnotations": { @@ -912,4 +953,3 @@ } } } -} diff --git a/charts/alertmanager/values.yaml b/charts/alertmanager/values.yaml index fa3b355a5114..154f343c12ec 100644 --- a/charts/alertmanager/values.yaml +++ b/charts/alertmanager/values.yaml @@ -235,6 +235,16 @@ topologySpreadConstraints: [] statefulSet: annotations: {} + ## 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 + ## +persistentVolumeClaimRetentionPolicy: + whenDeleted: Delete + whenScaled: Delete + podAnnotations: {} podLabels: {}