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

[kube-prometheus-stack] Add AlertmanagerConfig v1beta1 CRD #4526

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 58.4.0
version: 58.5.0
appVersion: v0.73.2
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
5,614 changes: 5,612 additions & 2 deletions charts/kube-prometheus-stack/charts/crds/crds/crd-alertmanagerconfigs.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagers.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: alertmanagers.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: podmonitors.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_probes.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: probes.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: prometheusagents.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: prometheuses.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusrules.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: prometheusrules.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_scrapeconfigs.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: scrapeconfigs.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: servicemonitors.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.73.2/example/prometheus-operator-crd-full/monitoring.coreos.com_thanosrulers.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
operator.prometheus.io/version: 0.73.2
name: thanosrulers.monitoring.coreos.com
spec:
group: monitoring.coreos.com
Expand Down
15 changes: 14 additions & 1 deletion charts/kube-prometheus-stack/hack/update_crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for line in "${FILES[@]}"; do
DESTINATION=$(echo "${line%%:*}" | xargs)
SOURCE=$(echo "${line##*:}" | xargs)

URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/$SOURCE"
URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd-full/$SOURCE"

echo -e "Downloading Prometheus Operator CRD with Version ${VERSION}:\n${URL}\n"

Expand All @@ -36,3 +36,16 @@ for line in "${FILES[@]}"; do
exit 1
fi
done

if ! curl --silent --retry-all-errors --fail --location "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/alertmanager-crd-conversion/patch.json" >> "${SCRIPT_DIR}/../charts/crds/crds/patch.json"; then
echo -e "Failed to download ${URL}!"
exit 1
fi

{
head -n1 "${SCRIPT_DIR}/../charts/crds/crds/crd-alertmanagerconfigs.yaml";
kubectl patch --local=true -f "${SCRIPT_DIR}/../charts/crds/crds/crd-alertmanagerconfigs.yaml" --patch-file="${SCRIPT_DIR}/../charts/crds/crds/patch.json" --type=merge --dry-run=client -o yaml
} >"${SCRIPT_DIR}/../charts/crds/crds/crd-alertmanagerconfigs.patched.yaml"

rm "${SCRIPT_DIR}/../charts/crds/crds/patch.json"
mv "${SCRIPT_DIR}/../charts/crds/crds/crd-alertmanagerconfigs.patched.yaml" "${SCRIPT_DIR}/../charts/crds/crds/crd-alertmanagerconfigs.yaml"
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,66 @@ webhooks:
{{- end }}
{{- end }}
{{- end }}
- name: alertmanagerconfigsvalidate.monitoring.coreos.com
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" }}
failurePolicy: {{ .Release.IsInstall | ternary "Ignore" "Fail" }}
{{- else if .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
failurePolicy: {{ .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
{{- else if .Values.prometheusOperator.admissionWebhooks.patch.enabled }}
failurePolicy: Ignore
{{- else }}
failurePolicy: Fail
{{- end }}
rules:
- apiGroups:
- monitoring.coreos.com
apiVersions:
- "*"
resources:
- alertmanagerconfigs
operations:
- CREATE
- UPDATE
clientConfig:
service:
namespace: {{ template "kube-prometheus-stack.namespace" . }}
name: {{ template "kube-prometheus-stack.operator.fullname" $ }}{{ if .Values.prometheusOperator.admissionWebhooks.deployment.enabled }}-webhook{{ end }}
path: /admission-alertmanagerconfigs/validate
{{- if and .Values.prometheusOperator.admissionWebhooks.caBundle (not .Values.prometheusOperator.admissionWebhooks.patch.enabled) (not .Values.prometheusOperator.admissionWebhooks.certManager.enabled) }}
caBundle: {{ .Values.prometheusOperator.admissionWebhooks.caBundle }}
{{- end }}
timeoutSeconds: {{ .Values.prometheusOperator.admissionWebhooks.timeoutSeconds }}
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces .Values.prometheusOperator.admissionWebhooks.namespaceSelector }}
namespaceSelector:
{{- with (omit .Values.prometheusOperator.admissionWebhooks.namespaceSelector "matchExpressions") }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces .Values.prometheusOperator.admissionWebhooks.namespaceSelector.matchExpressions }}
matchExpressions:
{{- with (.Values.prometheusOperator.admissionWebhooks.namespaceSelector.matchExpressions) }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.prometheusOperator.denyNamespaces }}
- key: kubernetes.io/metadata.name
operator: NotIn
values:
{{- range $namespace := mustUniq .Values.prometheusOperator.denyNamespaces }}
- {{ $namespace }}
{{- end }}
{{- else if and .Values.prometheusOperator.namespaces .Values.prometheusOperator.namespaces.additional }}
- key: kubernetes.io/metadata.name
operator: In
values:
{{- if and .Values.prometheusOperator.namespaces.releaseNamespace (default .Values.prometheusOperator.namespaces.releaseNamespace true) }}
{{- $namespace := printf "%s" (include "kube-prometheus-stack.namespace" .) }}
- {{ $namespace }}
{{- end }}
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
- {{ $namespace }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}