Skip to content

feat: support namespaced webhook configurations for multi-operator deployments#890

Open
maxlengdell wants to merge 1 commit into
cloudnative-pg:mainfrom
maxlengdell:dev/889
Open

feat: support namespaced webhook configurations for multi-operator deployments#890
maxlengdell wants to merge 1 commit into
cloudnative-pg:mainfrom
maxlengdell:dev/889

Conversation

@maxlengdell

Copy link
Copy Markdown

Add config.namespacedWebhooks option that, when enabled:

  • Appends the operator namespace to webhook configuration names
  • Sets ENABLE_WEBHOOK_NAMESPACE_SUFFIX env var on the operator
  • Adds namespaceSelector to webhook entries to scope them to the operator's namespace

This allows multiple CloudNativePG operators to run in single-namespace mode on the same cluster without webhook name collisions.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 1, 2026
@maxlengdell

Copy link
Copy Markdown
Author

Should also update the ClusterRole and ClusterRoleBinding convention

@maxlengdell maxlengdell marked this pull request as draft June 8, 2026 11:51
…ployments

When config.namespacedWebhooks is enabled and multiple operators share
the same release name in different namespaces, the ClusterRoleBinding
name collides and the second install overwrites the first, revoking
permissions from the earlier operator.

Append the operator namespace to the ClusterRoleBinding name (matching
the existing webhook configuration name suffixing). The ClusterRole
itself remains shared since permissions are identical across instances.

Signed-off-by: Max Lengdell <max.a.lengdell@ericsson.com>
@maxlengdell maxlengdell marked this pull request as ready for review June 18, 2026 08:02
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 18, 2026
clusterWide: true
# -- When set to true, appends the operator namespace to webhook configuration
# names to avoid collisions when running multiple operators in namespaced mode.
namespacedWebhooks: false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to fold this into clusterWide so that if clusterWide is false the webhooks are always namespaced?

I also wonder if this feature could allow for moving the webhooks permissions from cluster-wide to commonRules, allowing them to be namespace scoped as well, which would greatly remove the cluster-wide permissions needed to install the operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants