Skip to content

Commit ed7cf08

Browse files
authored
[prometheus-operator-crds] add opt-out for CRDs (#5533)
Signed-off-by: Simon Berz <[email protected]>
1 parent 995b339 commit ed7cf08

13 files changed

+109
-32
lines changed

Diff for: charts/prometheus-operator-crds/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
type: application
3-
version: 19.0.0
3+
version: 19.1.0
44
name: prometheus-operator-crds
55
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png
66
description: |

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-alertmanagerconfigs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.alertmanagerconfigs.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -10039,3 +10040,4 @@ spec:
1003910040
type: object
1004010041
served: true
1004110042
storage: true
10043+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-alertmanagers.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.alertmanagers.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -9134,3 +9135,4 @@ spec:
91349135
specReplicasPath: .spec.replicas
91359136
statusReplicasPath: .status.replicas
91369137
status: {}
9138+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-podmonitors.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.podmonitors.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -1209,3 +1210,4 @@ spec:
12091210
type: object
12101211
served: true
12111212
storage: true
1213+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-probes.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.probes.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -1176,3 +1177,4 @@ spec:
11761177
type: object
11771178
served: true
11781179
storage: true
1180+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheusagents.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.prometheusagents.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -10839,3 +10840,4 @@ spec:
1083910840
specReplicasPath: .spec.shards
1084010841
statusReplicasPath: .status.shards
1084110842
status: {}
10843+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheuses.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.prometheuses.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -13090,3 +13091,4 @@ spec:
1309013091
specReplicasPath: .spec.shards
1309113092
statusReplicasPath: .status.shards
1309213093
status: {}
13094+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheusrules.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.prometheusrules.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -161,3 +162,4 @@ spec:
161162
type: object
162163
served: true
163164
storage: true
165+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-scrapeconfigs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.scrapeconfigs.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -12516,3 +12517,4 @@ spec:
1251612517
type: object
1251712518
served: true
1251812519
storage: true
12520+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-servicemonitors.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.servicemonitors.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -1231,3 +1232,4 @@ spec:
12311232
type: object
12321233
served: true
12331234
storage: true
1235+
{{- end -}}

Diff for: charts/prometheus-operator-crds/charts/crds/templates/crd-thanosrulers.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.thanosrulers.enabled -}}
12
# https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.81.0/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
23
---
34
apiVersion: apiextensions.k8s.io/v1
@@ -8155,3 +8156,4 @@ spec:
81558156
storage: true
81568157
subresources:
81578158
status: {}
8159+
{{- end -}}

Diff for: charts/prometheus-operator-crds/hack/update_crds.sh

+36-30
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
#!/bin/bash
2+
set -euo pipefail
23

3-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
45

56
if [[ $(uname -s) = "Darwin" ]]; then
6-
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion: //g')"
7+
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion: //g')"
78
else
8-
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion:\s//g')"
9+
VERSION="$(grep ^appVersion "${SCRIPT_DIR}/../Chart.yaml" | sed 's/appVersion:\s//g')"
910
fi
1011

11-
FILES=(
12-
"crd-alertmanagerconfigs.yaml : monitoring.coreos.com_alertmanagerconfigs.yaml"
13-
"crd-alertmanagers.yaml : monitoring.coreos.com_alertmanagers.yaml"
14-
"crd-podmonitors.yaml : monitoring.coreos.com_podmonitors.yaml"
15-
"crd-probes.yaml : monitoring.coreos.com_probes.yaml"
16-
"crd-prometheusagents.yaml : monitoring.coreos.com_prometheusagents.yaml"
17-
"crd-prometheuses.yaml : monitoring.coreos.com_prometheuses.yaml"
18-
"crd-prometheusrules.yaml : monitoring.coreos.com_prometheusrules.yaml"
19-
"crd-scrapeconfigs.yaml : monitoring.coreos.com_scrapeconfigs.yaml"
20-
"crd-servicemonitors.yaml : monitoring.coreos.com_servicemonitors.yaml"
21-
"crd-thanosrulers.yaml : monitoring.coreos.com_thanosrulers.yaml"
12+
CRDS=(
13+
"alertmanagerconfigs : monitoring.coreos.com_alertmanagerconfigs.yaml"
14+
"alertmanagers : monitoring.coreos.com_alertmanagers.yaml"
15+
"podmonitors : monitoring.coreos.com_podmonitors.yaml"
16+
"probes : monitoring.coreos.com_probes.yaml"
17+
"prometheusagents : monitoring.coreos.com_prometheusagents.yaml"
18+
"prometheuses : monitoring.coreos.com_prometheuses.yaml"
19+
"prometheusrules : monitoring.coreos.com_prometheusrules.yaml"
20+
"scrapeconfigs : monitoring.coreos.com_scrapeconfigs.yaml"
21+
"servicemonitors : monitoring.coreos.com_servicemonitors.yaml"
22+
"thanosrulers : monitoring.coreos.com_thanosrulers.yaml"
2223
)
2324

24-
for line in "${FILES[@]}"; do
25-
DESTINATION=$(echo "${line%%:*}" | xargs)
26-
SOURCE=$(echo "${line##*:}" | xargs)
25+
for line in "${CRDS[@]}"; do
26+
CRD=$(echo "${line%%:*}" | xargs)
27+
SOURCE=$(echo "${line##*:}" | xargs)
28+
DESTINATION="crd-${CRD}".yaml
2729

28-
URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/$SOURCE"
30+
URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/$SOURCE"
2931

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

32-
echo "# ${URL}" > "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
34+
echo "# ${URL}" >"${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
3335

34-
if ! curl --silent --retry-all-errors --fail --location "${URL}" >> "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"; then
35-
echo -e "Failed to download ${URL}!"
36-
exit 1
37-
fi
36+
if ! curl --silent --retry-all-errors --fail --location "${URL}" >>"${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"; then
37+
echo -e "Failed to download ${URL}!"
38+
exit 1
39+
fi
3840

39-
# Update or insert annotations block
40-
if yq -e '.metadata.annotations' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}" >/dev/null; then
41-
sed -i '/^ annotations:$/a {{- with .Values.annotations }}\n{{- toYaml . | nindent 4 }}\n{{- end }}' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
42-
else
43-
sed -i '/^metadata:$/a {{- with .Values.annotations }}\n annotations:\n{{- toYaml . | nindent 4 }}\n{{- end }}' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
44-
fi
41+
# Update or insert annotations block
42+
if yq -e '.metadata.annotations' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}" >/dev/null; then
43+
sed -i '/^ annotations:$/a {{- with .Values.annotations }}\n{{- toYaml . | nindent 4 }}\n{{- end }}' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
44+
else
45+
sed -i '/^metadata:$/a {{- with .Values.annotations }}\n annotations:\n{{- toYaml . | nindent 4 }}\n{{- end }}' "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
46+
fi
47+
48+
# Insert enable option
49+
sed -i "1i\{{- if .Values.${CRD}.enabled -}}" "${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
50+
echo "{{- end -}}" >>"${SCRIPT_DIR}/../charts/crds/templates/${DESTINATION}"
4551
done

Diff for: charts/prometheus-operator-crds/values.yaml

+52-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
1-
## Annotations for CRDs
1+
## Settings for CRDs
22
##
33
crds:
4+
## annotations add additional annotations to all CRDs
45
annotations: {}
6+
7+
## alertmanagerconfigs configures the AlertManagerConfig CRD
8+
alertmanagerconfigs:
9+
## enabled defines if the CRD should be installed
10+
enabled: true
11+
12+
## alertmanagers configures the AlertManager CRD
13+
alertmanagers:
14+
## enabled defines if the CRD should be installed
15+
enabled: true
16+
17+
## podmonitors configures the PodMonitor CRD
18+
podmonitors:
19+
## enabled defines if the CRD should be installed
20+
enabled: true
21+
22+
## probes configures the Probe CRD
23+
probes:
24+
## enabled defines if the CRD should be installed
25+
enabled: true
26+
27+
## prometheusagents configures the PrometheusAgent CRD
28+
prometheusagents:
29+
## enabled defines if the CRD should be installed
30+
enabled: true
31+
32+
## prometheuses configures the Prometheus CRD
33+
prometheuses:
34+
## enabled defines if the CRD should be installed
35+
enabled: true
36+
37+
## prometheusrules configures the PrometheusRule CRD
38+
prometheusrules:
39+
## enabled defines if the CRD should be installed
40+
enabled: true
41+
42+
## prometheusrules configures the PrometheusRule CRD
43+
scrapeconfigs:
44+
## enabled defines if the CRD should be installed
45+
enabled: true
46+
47+
## servicemonitors configures the ServiceMonitor CRD
48+
servicemonitors:
49+
## enabled defines if the CRD should be installed
50+
enabled: true
51+
52+
## thanosrulers configures the ThanosRuler CRD
53+
thanosrulers:
54+
## enabled defines if the CRD should be installed
55+
enabled: true

0 commit comments

Comments
 (0)