Skip to content

Commit 487bb85

Browse files
authored
[kube-prometheus-stack] Support validating AlertmanagerConfigs (#6244)
1 parent 47e4d7c commit 487bb85

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

charts/kube-prometheus-stack/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ name: kube-prometheus-stack
3131
sources:
3232
- https://github.com/prometheus-community/helm-charts
3333
- https://github.com/prometheus-operator/kube-prometheus
34-
version: 78.2.1
34+
version: 78.3.0
3535
# renovate: github=prometheus-operator/prometheus-operator
3636
appVersion: v0.86.0
3737
kubeVersion: ">=1.25.0-0"

charts/kube-prometheus-stack/templates/prometheus-operator/admission-webhooks/validatingWebhookConfiguration.yaml

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ metadata:
1212
app: {{ template "kube-prometheus-stack.name" $ }}-admission
1313
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
1414
webhooks:
15-
- name: prometheusrulemutate.monitoring.coreos.com
15+
- name: prometheusrulevalidate.monitoring.coreos.com
1616
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" }}
1717
failurePolicy: {{ .Release.IsInstall | ternary "Ignore" "Fail" }}
1818
{{- else if .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
@@ -82,4 +82,74 @@ webhooks:
8282
matchConditions:
8383
{{- toYaml . | nindent 6 }}
8484
{{- end }}
85+
- name: alertmanagerconfigsvalidate.monitoring.coreos.com
86+
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" }}
87+
failurePolicy: {{ .Release.IsInstall | ternary "Ignore" "Fail" }}
88+
{{- else if .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
89+
failurePolicy: {{ .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
90+
{{- else if .Values.prometheusOperator.admissionWebhooks.patch.enabled }}
91+
failurePolicy: Ignore
92+
{{- else }}
93+
failurePolicy: Fail
94+
{{- end }}
95+
rules:
96+
- apiGroups:
97+
- monitoring.coreos.com
98+
apiVersions:
99+
- v1alpha1
100+
resources:
101+
- alertmanagerconfigs
102+
operations:
103+
- CREATE
104+
- UPDATE
105+
clientConfig:
106+
service:
107+
namespace: {{ template "kube-prometheus-stack.namespace" . }}
108+
name: {{ template "kube-prometheus-stack.operator.fullname" $ }}{{ if .Values.prometheusOperator.admissionWebhooks.deployment.enabled }}-webhook{{ end }}
109+
path: /admission-alertmanagerconfigs/validate
110+
{{- if and .Values.prometheusOperator.admissionWebhooks.caBundle (not .Values.prometheusOperator.admissionWebhooks.patch.enabled) (not .Values.prometheusOperator.admissionWebhooks.certManager.enabled) }}
111+
caBundle: {{ .Values.prometheusOperator.admissionWebhooks.caBundle }}
112+
{{- end }}
113+
timeoutSeconds: {{ .Values.prometheusOperator.admissionWebhooks.timeoutSeconds }}
114+
admissionReviewVersions: ["v1", "v1beta1"]
115+
sideEffects: None
116+
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces .Values.prometheusOperator.admissionWebhooks.namespaceSelector }}
117+
namespaceSelector:
118+
{{- with (omit .Values.prometheusOperator.admissionWebhooks.namespaceSelector "matchExpressions") }}
119+
{{- toYaml . | nindent 6 }}
120+
{{- end }}
121+
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces .Values.prometheusOperator.admissionWebhooks.namespaceSelector.matchExpressions }}
122+
matchExpressions:
123+
{{- with (.Values.prometheusOperator.admissionWebhooks.namespaceSelector.matchExpressions) }}
124+
{{- toYaml . | nindent 8 }}
125+
{{- end }}
126+
{{- if .Values.prometheusOperator.denyNamespaces }}
127+
- key: kubernetes.io/metadata.name
128+
operator: NotIn
129+
values:
130+
{{- range $namespace := mustUniq .Values.prometheusOperator.denyNamespaces }}
131+
- {{ $namespace }}
132+
{{- end }}
133+
{{- else if and .Values.prometheusOperator.namespaces .Values.prometheusOperator.namespaces.additional }}
134+
- key: kubernetes.io/metadata.name
135+
operator: In
136+
values:
137+
{{- if and .Values.prometheusOperator.namespaces.releaseNamespace (default .Values.prometheusOperator.namespaces.releaseNamespace true) }}
138+
{{- $namespace := printf "%s" (include "kube-prometheus-stack.namespace" .) }}
139+
- {{ $namespace }}
140+
{{- end }}
141+
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
142+
- {{ $namespace }}
143+
{{- end }}
144+
{{- end }}
145+
{{- end }}
146+
{{- end }}
147+
{{- with .Values.prometheusOperator.admissionWebhooks.objectSelector }}
148+
objectSelector:
149+
{{- toYaml . | nindent 6 }}
150+
{{- end }}
151+
{{- with .Values.prometheusOperator.admissionWebhooks.matchConditions }}
152+
matchConditions:
153+
{{- toYaml . | nindent 6 }}
154+
{{- end }}
85155
{{- end }}

0 commit comments

Comments
 (0)