From 7cf98751c51874a7603a67bb1b6df4aa9efd854a Mon Sep 17 00:00:00 2001 From: SHA65536 <53488697+SHA65536@users.noreply.github.com> Date: Sun, 27 Jul 2025 13:55:34 +0300 Subject: [PATCH] feat: add option for namespace selection for telegraf-operator webhook --- charts/telegraf-operator/Chart.yaml | 2 +- charts/telegraf-operator/templates/_helpers.tpl | 5 +++++ .../templates/mutatingwebhookconfiguration.yml | 5 +++++ charts/telegraf-operator/values.yaml | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/charts/telegraf-operator/Chart.yaml b/charts/telegraf-operator/Chart.yaml index 15b0deb5..0320cc06 100644 --- a/charts/telegraf-operator/Chart.yaml +++ b/charts/telegraf-operator/Chart.yaml @@ -30,7 +30,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 1.4.0 +version: 1.5.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. diff --git a/charts/telegraf-operator/templates/_helpers.tpl b/charts/telegraf-operator/templates/_helpers.tpl index 3db3ead8..574e1709 100644 --- a/charts/telegraf-operator/templates/_helpers.tpl +++ b/charts/telegraf-operator/templates/_helpers.tpl @@ -99,6 +99,11 @@ webhooks: - DELETE resources: - pods + {{- if not (empty .Values.namespaceSelector) }} + scope: "Namespaced" + {{- end }} + namespaceSelector: + {{- toYaml .Values.namespaceSelector | nindent 4 }} --- apiVersion: v1 kind: Secret diff --git a/charts/telegraf-operator/templates/mutatingwebhookconfiguration.yml b/charts/telegraf-operator/templates/mutatingwebhookconfiguration.yml index 33e022c9..77255ff1 100644 --- a/charts/telegraf-operator/templates/mutatingwebhookconfiguration.yml +++ b/charts/telegraf-operator/templates/mutatingwebhookconfiguration.yml @@ -28,4 +28,9 @@ webhooks: - DELETE resources: - pods + {{- if not (empty .Values.namespaceSelector) }} + scope: "Namespaced" + {{- end }} + namespaceSelector: + {{- toYaml .Values.namespaceSelector | nindent 4 }} {{- end }} diff --git a/charts/telegraf-operator/values.yaml b/charts/telegraf-operator/values.yaml index 93303719..681348ff 100644 --- a/charts/telegraf-operator/values.yaml +++ b/charts/telegraf-operator/values.yaml @@ -57,3 +57,4 @@ enableDefaultInternalPlugin: true # allow hot reload ; disabled by default to support versions of telegraf # that do not support hot-reload and --watch-config flag hotReload: false +namespaceSelector: {}