Skip to content

Commit

Permalink
[kube-prometheus-stack] Label promstack-operator pods with k8s recomm…
Browse files Browse the repository at this point in the history
…ended labels (#4094)

Co-authored-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
koooge and jkroepke authored Jan 20, 2024
1 parent 94b3391 commit 120ab8f
Show file tree
Hide file tree
Showing 34 changed files with 66 additions and 72 deletions.
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: 56.0.0
version: 56.0.1
appVersion: v0.71.0
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{/* Generate basic labels for prometheus-operator */}}
{{- define "kube-prometheus-stack.prometheus-operator.labels" }}
{{- include "kube-prometheus-stack.labels" . }}
app: {{ template "kube-prometheus-stack.name" . }}-operator
app.kubernetes.io/name: {{ template "kube-prometheus-stack.name" . }}-prometheus-operator
app.kubernetes.io/component: prometheus-operator
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{/* Generate basic labels for prometheus-operator-webhook */}}
{{- define "kube-prometheus-stack.prometheus-operator-webhook.labels" }}
{{- include "kube-prometheus-stack.labels" . }}
app.kubernetes.io/name: {{ template "kube-prometheus-stack.name" . }}-prometheus-operator
app.kubernetes.io/component: prometheus-operator-webhook
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator-webhook
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | nindent 4 }}
{{- if .Values.prometheusOperator.admissionWebhooks.deployment.labels }}
{{ toYaml .Values.prometheusOperator.admissionWebhooks.deployment.labels | indent 4 }}
{{- end }}
Expand All @@ -25,6 +25,7 @@ spec:
metadata:
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator-webhook
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | nindent 8 }}
release: {{ $.Release.Name | quote }}
{{- if .Values.prometheusOperator.admissionWebhooks.deployment.podLabels }}
{{ toYaml .Values.prometheusOperator.admissionWebhooks.deployment.podLabels | indent 8 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator-webhook
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
{{- include "kube-prometheus-stack.labels" . | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator-webhook
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | nindent 4 }}
{{- if .Values.prometheusOperator.admissionWebhooks.deployment.service.labels }}
{{ toYaml .Values.prometheusOperator.admissionWebhooks.deployment.service.labels | indent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ metadata:
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
app.kubernetes.io/name: {{ template "kube-prometheus-stack.name" . }}-prometheus-operator
app.kubernetes.io/component: prometheus-operator-webhook
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | indent 4 }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{ include "kube-prometheus-stack.imagePullSecrets" . | trim | indent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ metadata:
helm.sh/hook-weight: "-5"
{{- with .Values.prometheusOperator.admissionWebhooks.annotations }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- include "kube-prometheus-stack.labels" $ | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
endpointSelector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- if .Values.prometheusOperator.networkPolicy.matchLabels }}
{{ toYaml .Values.prometheusOperator.networkPolicy.matchLabels | nindent 6 }}
{{- else }}
{{- include "kube-prometheus-stack.labels" $ | nindent 6 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 6 }}
{{- end }}
egress:
{{- if and .Values.prometheusOperator.networkPolicy.cilium .Values.prometheusOperator.networkPolicy.cilium.egress }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ metadata:
helm.sh/hook-weight: "-5"
{{- with .Values.prometheusOperator.admissionWebhooks.patch.annotations }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- include "kube-prometheus-stack.labels" $ | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
endpointSelector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- if .Values.prometheusOperator.networkPolicy.matchLabels }}
{{ toYaml .Values.prometheusOperator.networkPolicy.matchLabels | nindent 6 }}
{{- else }}
{{- include "kube-prometheus-stack.labels" $ | nindent 6 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 6 }}
{{- end }}
egress:
{{- if and .Values.prometheusOperator.networkPolicy.cilium .Values.prometheusOperator.networkPolicy.cilium.egress }}
Expand All @@ -34,4 +34,3 @@ spec:
{{- end }}
{{- end }}
{{- end }}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
rules:
- apiGroups:
- admissionregistration.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- with .Values.prometheusOperator.admissionWebhooks.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
{{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }}
# Alpha feature since k8s 1.12
Expand All @@ -27,7 +27,7 @@ spec:
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- include "kube-prometheus-stack.labels" $ | indent 8 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 8 }}
spec:
{{- if .Values.prometheusOperator.admissionWebhooks.patch.priorityClassName }}
priorityClassName: {{ .Values.prometheusOperator.admissionWebhooks.patch.priorityClassName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- with .Values.prometheusOperator.admissionWebhooks.patch.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
{{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }}
# Alpha feature since k8s 1.12
Expand All @@ -27,7 +27,7 @@ spec:
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- include "kube-prometheus-stack.labels" $ | indent 8 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 8 }}
spec:
{{- if .Values.prometheusOperator.admissionWebhooks.patch.priorityClassName }}
priorityClassName: {{ .Values.prometheusOperator.admissionWebhooks.patch.priorityClassName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ metadata:
"helm.sh/hook-weight": "-5"
{{- with .Values.prometheusOperator.admissionWebhooks.annotations }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- include "kube-prometheus-stack.labels" $ | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
podSelector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-create
{{- if .Values.prometheusOperator.networkPolicy.matchLabels }}
{{ toYaml .Values.prometheusOperator.networkPolicy.matchLabels | nindent 6 }}
{{- else }}
{{- include "kube-prometheus-stack.labels" $ | nindent 6 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 6 }}
{{- end }}
egress:
- {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ metadata:
"helm.sh/hook-weight": "-5"
{{- with .Values.prometheusOperator.admissionWebhooks.patch.annotations }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- include "kube-prometheus-stack.labels" $ | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
spec:
podSelector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission-patch
{{- if .Values.prometheusOperator.networkPolicy.matchLabels }}
{{ toYaml .Values.prometheusOperator.networkPolicy.matchLabels | nindent 6 }}
{{- else }}
{{- include "kube-prometheus-stack.labels" $ | nindent 6 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 6 }}
{{- end }}
egress:
- {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-admission
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" . | nindent 4 }}
spec:
privileged: false
# Allow core volume types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{ include "kube-prometheus-stack.imagePullSecrets" . | trim | indent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
webhooks:
- name: prometheusrulemutate.monitoring.coreos.com
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" }}
Expand Down Expand Up @@ -57,7 +57,7 @@ webhooks:
- key: kubernetes.io/metadata.name
operator: NotIn
values:
{{- range $namespace := mustUniq .Values.prometheusOperator.denyNamespaces }}
{{- range $namespace := mustUniq .Values.prometheusOperator.denyNamespaces }}
- {{ $namespace }}
{{- end }}
{{- else if and .Values.prometheusOperator.namespaces .Values.prometheusOperator.namespaces.additional }}
Expand All @@ -68,7 +68,7 @@ webhooks:
{{- $namespace := printf "%s" (include "kube-prometheus-stack.namespace" .) }}
- {{ $namespace }}
{{- end }}
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
- {{ $namespace }}
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" $ }}-admission
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator-webhook.labels" $ | nindent 4 }}
webhooks:
- name: prometheusrulemutate.monitoring.coreos.com
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ metadata:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{- include "kube-prometheus-stack.labels" . | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
rules:
- apiGroups: ["monitoring.coreos.com"]
resources: ["alertmanagers", "alertmanagerconfigs", "podmonitors", "probes", "prometheuses", "prometheusagents", "prometheusrules", "scrapeconfigs", "servicemonitors"]
Expand All @@ -22,8 +21,7 @@ metadata:
labels:
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-admin: "true"
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{- include "kube-prometheus-stack.labels" . | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
rules:
- apiGroups: ["monitoring.coreos.com"]
resources: ["alertmanagers", "alertmanagerconfigs", "podmonitors", "probes", "prometheuses", "prometheusagents", "prometheusrules", "scrapeconfigs", "servicemonitors"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{- include "kube-prometheus-stack.labels" . | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
spec:
endpointSelector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{- if .Values.prometheusOperator.networkPolicy.matchLabels }}
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{ toYaml .Values.prometheusOperator.networkPolicy.matchLabels | nindent 6 }}
{{- else }}
{{- include "kube-prometheus-stack.labels" $ | nindent 6 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" $ | nindent 6 }}
{{- end }}
egress:
{{- if and .Values.prometheusOperator.networkPolicy.cilium .Values.prometheusOperator.networkPolicy.cilium.egress }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ kind: ClusterRole
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
rules:
- apiGroups:
- monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
{{- if .Values.prometheusOperator.labels }}
{{ toYaml .Values.prometheusOperator.labels | indent 4 }}
{{- end }}
Expand All @@ -26,8 +25,7 @@ spec:
template:
metadata:
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{ include "kube-prometheus-stack.labels" . | indent 8 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 8 }}
{{- if .Values.prometheusOperator.podLabels }}
{{ toYaml .Values.prometheusOperator.podLabels | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -117,7 +115,7 @@ spec:
- --thanos-default-base-image={{ $thanosRegistry }}/{{ .Values.prometheusOperator.thanosImage.repository }}:{{ .Values.prometheusOperator.thanosImage.tag }}@sha256:{{ .Values.prometheusOperator.thanosImage.sha }}
{{- else }}
- --thanos-default-base-image={{ $thanosRegistry }}/{{ .Values.prometheusOperator.thanosImage.repository }}:{{ .Values.prometheusOperator.thanosImage.tag }}
{{- end }}
{{- end }}
{{- if .Values.prometheusOperator.thanosRulerInstanceNamespaces }}
- --thanos-ruler-instance-namespaces={{ .Values.prometheusOperator.thanosRulerInstanceNamespaces | join "," }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-operator
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-operator
{{- include "kube-prometheus-stack.labels" . | nindent 4 }}
{{- include "kube-prometheus-stack.prometheus-operator.labels" . | nindent 4 }}
spec:
egress:
egress:
- {}
ingress:
- ports:
Expand Down
Loading

0 comments on commit 120ab8f

Please sign in to comment.