clickhouse-operator icon indicating copy to clipboard operation
clickhouse-operator copied to clipboard

fix(helm): wire watchNamespaces value into operator ConfigMap

Open jtomaszon opened this issue 5 months ago • 0 comments

Problem

Closes #1919.

configs.files.config.yaml.watch.namespaces.include is hardcoded to [] in values.yaml and the ConfigMap template renders it directly — there is no way to override it via a top-level Helm value. Users who need the operator to watch multiple namespaces must manually patch the ConfigMap after install, which is fragile and breaks on upgrades.

Solution

This PR introduces:

  1. A top-level watchNamespaces value in values.yaml (empty by default — preserves existing behavior):
# 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.
watchNamespaces: []
  1. A new altinity-clickhouse-operator.configmap-files helper in _helpers.tpl that deep-copies configs.files, patches watch.namespaces.include in-place, and delegates to the existing configmap-data helper for rendering.

  2. The ConfigMap template updated to call the new helper instead of configmap-data directly.

Usage

# values.yaml
watchNamespaces:
  - clickhouse-system
  - my-app-namespace

Or via --set:

helm install clickhouse-operator altinity/altinity-clickhouse-operator \
  --set "watchNamespaces={clickhouse-system,my-app-namespace}"

Behavior

  • watchNamespaces: [] (default) — no change, operator watches its own namespace
  • watchNamespaces: [".*"] — watch all namespaces
  • Any non-empty list — operator watches exactly those namespaces

Testing

# Default — include stays []
helm template test deploy/helm/clickhouse-operator \
  --show-only templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml | grep -A5 'watch:'

# With namespaces set
helm template test deploy/helm/clickhouse-operator \
  --set 'watchNamespaces={clickhouse-system,everest-dev}' \
  --show-only templates/generated/ConfigMap-etc-clickhouse-operator-files.yaml | grep -A8 'watch:'

jtomaszon avatar Jun 06 '26 11:06 jtomaszon