Skip to content

Commit

Permalink
[kube-prometheus-stack] fix failure-policy on patch-webhook job
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Badstübner <[email protected]>
  • Loading branch information
jonasbadstuebner committed Dec 20, 2023
1 parent 8f37709 commit aa3fcec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 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.5.0
version: 55.5.1
appVersion: v0.70.0
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
17 changes: 17 additions & 0 deletions charts/kube-prometheus-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,20 @@ global:
{{ $fullname }}-webhook.{{ $namespace }}.svc
{{- end }}
{{- end }}

{{/*
Defines the failurePolicy, which is "Ignore" or "Fail".
If failurePolicy is set to "IgnoreOnInstallOnly":
If Release.IsInstall returns "true", returns "Ignore" otherwise "Fail"
*/}}
{{- define "kube-prometheus-stack.operator.admission-webhook.failurePolicy" -}}
{{- if eq .Values.prometheusOperator.admissionWebhooks.failurePolicy "IgnoreOnInstallOnly" -}}
{{ .Release.IsInstall | ternary "Ignore" "Fail" -}}
{{- else if .Values.prometheusOperator.admissionWebhooks.failurePolicy -}}
{{ .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
{{- else if .Values.prometheusOperator.admissionWebhooks.patch.enabled -}}
Ignore
{{- else -}}
Fail
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
- --webhook-name={{ template "kube-prometheus-stack.fullname" . }}-admission
- --namespace={{ template "kube-prometheus-stack.namespace" . }}
- --secret-name={{ template "kube-prometheus-stack.fullname" . }}-admission
- --patch-failure-policy={{ .Values.prometheusOperator.admissionWebhooks.failurePolicy }}
- --patch-failure-policy={{ include "kube-prometheus-stack.operator.admission-webhook.failurePolicy" $ }}
{{- with .Values.prometheusOperator.admissionWebhooks.patchWebhookJob }}
securityContext:
{{ toYaml .securityContext | nindent 12 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ metadata:
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
webhooks:
- name: prometheusrulemutate.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 }}
failurePolicy: {{ include "kube-prometheus-stack.operator.admission-webhook.failurePolicy" $ }}
rules:
- apiGroups:
- monitoring.coreos.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ metadata:
{{- include "kube-prometheus-stack.labels" $ | indent 4 }}
webhooks:
- name: prometheusrulemutate.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 }}
failurePolicy: {{ include "kube-prometheus-stack.operator.admission-webhook.failurePolicy" $ }}
rules:
- apiGroups:
- monitoring.coreos.com
Expand Down

0 comments on commit aa3fcec

Please sign in to comment.