Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[alertmanager] Add support for PVC retention policy in statefulset #3760

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added alertmanager.kubeVersion
Empty file.
2 changes: 1 addition & 1 deletion charts/alertmanager/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions charts/alertmanager/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Get KubeVersion removing pre-release information.
*/}}
{{- define "alertmanager.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version (regexFind "v[0-9]+\\.[0-9]+\\.[0-9]+" .Capabilities.KubeVersion.Version) -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down
5 changes: 5 additions & 0 deletions charts/alertmanager/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ metadata:
{{- end }}
namespace: {{ include "alertmanager.namespace" . }}
spec:
{{- if semverCompare ">= 1.27-0" .Capabilities.KubeVersion.Version }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.statefulSet.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ .Values.statefulSet.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{- end }}
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
Expand Down
53 changes: 51 additions & 2 deletions charts/alertmanager/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,56 @@
"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"
},
"persistentVolumeClaimRetentionPolicy": {
"type": "object",
"properties": {
"whenDeleted": {
"type": "string",
"enum": ["Retain", "Delete"]
},
"whenScaled": {
"type": "string",
"enum": ["Retain", "Delete"]
}
},
"additionalProperties": false,
"required": ["whenDeleted", "whenScaled"]
}
}
},
"podAnnotations": {
Expand Down Expand Up @@ -912,4 +961,4 @@
}
}
}
}
monotek marked this conversation as resolved.
Show resolved Hide resolved
}
10 changes: 10 additions & 0 deletions charts/alertmanager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ persistence:
- ReadWriteOnce
size: 50Mi

## 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: Retain
whenScaled: Retain

configAnnotations: {}
## For example if you want to provide private data from a secret vault
## https://github.com/banzaicloud/bank-vaults/tree/main/charts/vault-secrets-webhook
Expand Down
Loading