From 3cde7770dd5bdc582d3bfc7e1307a04b6a80c094 Mon Sep 17 00:00:00 2001 From: Adrian Berger <43774417+adberger@users.noreply.github.com> Date: Tue, 27 Aug 2024 01:35:17 +0200 Subject: [PATCH] Chart: Add `controller.metrics.prometheusRule.annotations`. (#11849) --- charts/ingress-nginx/README.md | 1 + .../templates/controller-prometheusrule.yaml | 3 +++ .../tests/controller-prometheusrule_test.yaml | 12 ++++++++++++ charts/ingress-nginx/values.yaml | 2 ++ 4 files changed, 18 insertions(+) diff --git a/charts/ingress-nginx/README.md b/charts/ingress-nginx/README.md index 3896ee9780..99551e6d49 100644 --- a/charts/ingress-nginx/README.md +++ b/charts/ingress-nginx/README.md @@ -372,6 +372,7 @@ As of version `1.26.0` of this chart, by simply not providing any clusterIP valu | controller.metrics.port | int | `10254` | | | controller.metrics.portName | string | `"metrics"` | | | controller.metrics.prometheusRule.additionalLabels | object | `{}` | | +| controller.metrics.prometheusRule.annotations | object | `{}` | Annotations to be added to the PrometheusRule. | | controller.metrics.prometheusRule.enabled | bool | `false` | | | controller.metrics.prometheusRule.rules | list | `[]` | | | controller.metrics.service.annotations | object | `{}` | | diff --git a/charts/ingress-nginx/templates/controller-prometheusrule.yaml b/charts/ingress-nginx/templates/controller-prometheusrule.yaml index 41684c3708..4a9357f710 100644 --- a/charts/ingress-nginx/templates/controller-prometheusrule.yaml +++ b/charts/ingress-nginx/templates/controller-prometheusrule.yaml @@ -14,6 +14,9 @@ metadata: {{- if .Values.controller.metrics.prometheusRule.additionalLabels }} {{- toYaml .Values.controller.metrics.prometheusRule.additionalLabels | nindent 4 }} {{- end }} + {{- if .Values.controller.metrics.prometheusRule.annotations }} + annotations: {{ toYaml .Values.controller.metrics.prometheusRule.annotations | nindent 4 }} + {{- end }} spec: {{- if .Values.controller.metrics.prometheusRule.rules }} groups: diff --git a/charts/ingress-nginx/tests/controller-prometheusrule_test.yaml b/charts/ingress-nginx/tests/controller-prometheusrule_test.yaml index d60a98315f..2d330919dd 100644 --- a/charts/ingress-nginx/tests/controller-prometheusrule_test.yaml +++ b/charts/ingress-nginx/tests/controller-prometheusrule_test.yaml @@ -15,3 +15,15 @@ tests: - equal: path: metadata.name value: RELEASE-NAME-ingress-nginx-controller + + - it: should create a PrometheusRule with annotations if `controller.metrics.prometheusRule.annotations` is set + set: + controller.metrics.enabled: true + controller.metrics.prometheusRule.enabled: true + controller.metrics.prometheusRule.annotations: + my-little-annotation: test-value + asserts: + - equal: + path: metadata.annotations + value: + my-little-annotation: test-value diff --git a/charts/ingress-nginx/values.yaml b/charts/ingress-nginx/values.yaml index a06093348c..46cfa089b0 100644 --- a/charts/ingress-nginx/values.yaml +++ b/charts/ingress-nginx/values.yaml @@ -899,6 +899,8 @@ controller: prometheusRule: enabled: false additionalLabels: {} + # -- Annotations to be added to the PrometheusRule. + annotations: {} # namespace: "" rules: [] # # These are just examples rules, please adapt them to your needs