Skip to content

Commit

Permalink
[kube-prometheus-stack] Add prometheusOperator.admissionWebhooks.name…
Browse files Browse the repository at this point in the history
…spaceSelector

Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Jan 13, 2024
1 parent 16219b7 commit 732b878
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 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 @@ -21,7 +21,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 55.4.0
version: 55.5.0
appVersion: v0.70.0
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
13 changes: 13 additions & 0 deletions charts/kube-prometheus-stack/ci/03-non-defaults-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ defaultRules:
kubernetesSystem:
key2: value2

prometheusOperator:
denyNamespaces:
- kube-system
admissionWebhooks:
namespaceSelector:
matchLabels:
key: value
matchExpressions:
- key: control-plane
operator: NotIn
values:
- "true"

alertmanager:
alertmanagerSpec:
additionalConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ webhooks:
timeoutSeconds: {{ .Values.prometheusOperator.admissionWebhooks.timeoutSeconds }}
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces }}
{{- 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:
{{- if .Values.prometheusOperator.denyNamespaces }}
{{- with (.Values.prometheusOperator.admissionWebhooks.namespaceSelector.matchExpressions) }}
{{- toYaml . | nindent 6 }}
{{- 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 }}
{{- else if and .Values.prometheusOperator.namespaces .Values.prometheusOperator.namespaces.additional }}
- key: kubernetes.io/metadata.name
operator: In
values:
Expand All @@ -64,6 +71,7 @@ webhooks:
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
- {{ $namespace }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,34 @@ webhooks:
timeoutSeconds: {{ .Values.prometheusOperator.admissionWebhooks.timeoutSeconds }}
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
{{- if or .Values.prometheusOperator.denyNamespaces .Values.prometheusOperator.namespaces }}
{{- 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:
{{- if .Values.prometheusOperator.denyNamespaces }}
- key: kubernetes.io/metadata.name
operator: NotIn
values:
{{- range $namespace := mustUniq .Values.prometheusOperator.denyNamespaces }}
- {{ $namespace }}
{{- 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:
{{- 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 }}
- {{ $namespace }}
{{- end }}
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
- {{ $namespace }}
{{- end }}
{{- range $namespace := mustUniq .Values.prometheusOperator.namespaces.additional }}
- {{ $namespace }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/kube-prometheus-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,8 @@ prometheusOperator:
# argocd.argoproj.io/hook: PreSync
# argocd.argoproj.io/hook-delete-policy: HookSucceeded

namespaceSelector: {}

deployment:
enabled: false

Expand Down

0 comments on commit 732b878

Please sign in to comment.