diff --git a/deploy/helm/clickhouse-operator/templates/_helpers.tpl b/deploy/helm/clickhouse-operator/templates/_helpers.tpl index f2d1aee2b..4cdabde82 100644 --- a/deploy/helm/clickhouse-operator/templates/_helpers.tpl +++ b/deploy/helm/clickhouse-operator/templates/_helpers.tpl @@ -122,3 +122,25 @@ null {{- tpl (toYaml (dict $k $v)) $root }} {{ end }} {{- end }} + +{{/* +altinity-clickhouse-operator.configmap-files merges watchNamespaces into the +operator config before rendering the ConfigMap data block. + +This exists because configs.files.config.yaml.watch.namespaces.include is +deep inside a nested structure — Helm's values merge cannot target it +directly. Instead we deepCopy the files map, patch the nested value in-place, +and pass the result to configmap-data. + +Arguments (list): root context, configs.files, watchNamespaces list +*/}} +{{- define "altinity-clickhouse-operator.configmap-files" -}} +{{- $root := index . 0 -}} +{{- $files := deepCopy (index . 1) -}} +{{- $watchNamespaces := index . 2 -}} +{{- if $watchNamespaces -}} + {{- $namespaces := index (index (index $files "config.yaml") "watch") "namespaces" -}} + {{- $_ := set $namespaces "include" $watchNamespaces -}} +{{- end -}} +{{- include "altinity-clickhouse-operator.configmap-data" (list $root $files) -}} +{{- end -}} diff --git a/deploy/helm/clickhouse-operator/templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml b/deploy/helm/clickhouse-operator/templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml index bc6d21dd1..df1886ac3 100644 --- a/deploy/helm/clickhouse-operator/templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml +++ b/deploy/helm/clickhouse-operator/templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml @@ -11,4 +11,4 @@ metadata: namespace: {{ include "altinity-clickhouse-operator.namespace" . }} labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }} annotations: {{ include "altinity-clickhouse-operator.annotations" . | nindent 4 }} -data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.files) | nindent 2 }} +data: {{ include "altinity-clickhouse-operator.configmap-files" (list . .Values.configs.files .Values.watchNamespaces) | nindent 2 }} diff --git a/deploy/helm/clickhouse-operator/values.yaml b/deploy/helm/clickhouse-operator/values.yaml index b7579fce9..c5ca1a8bd 100644 --- a/deploy/helm/clickhouse-operator/values.yaml +++ b/deploy/helm/clickhouse-operator/values.yaml @@ -147,6 +147,11 @@ podAnnotations: prometheus.io/scrape: 'true' clickhouse-operator-metrics/port: '9999' clickhouse-operator-metrics/scrape: 'true' +# watchNamespaces -- namespaces where the operator watches for ClickHouseInstallation resources. +# If empty, the operator watches only its own namespace (or all namespaces when running in kube-system). +# Use [".*"] to watch all namespaces. +# Example: watchNamespaces: ["clickhouse", "my-other-namespace"] +watchNamespaces: [] # nameOverride -- override name of the chart nameOverride: "" # fullnameOverride -- full name of the chart.