Skip to content

[Feature]: Make webhook dependency optional #9278

Closed

Description

@maxlengdell

Is there an existing issue already for this feature request/idea?

  • I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.

What problem is this feature going to solve? Why should it be added?

In a deployment with strict security requirements, cluster wide resources and namespaced resources are packaged separately. Cluster wide resources like CRDs which are deployed by a cluster admin and namespaced resources can then be installed with lower permissions. CNPG requires cluster-wide access by the k8 admin deploying the operator.

CNPG is currently dependent on the webhooks at startup. Deploying admission webhooks MutatingWebhookConfiguration and ValidatingWebhookConfiguration require cluster admin rights.

  • Organizations with strict RBAC policies don't grant cluster-admin permissions to deployment engineers.
  • A webhook has access to all resources in the cluster of the subscribed type.
  • While webhooks can be limited to specific namespaces using namespace selectors, running multiple CNPG operators on the same cluster requires complex customization to avoid webhook configuration name conflicts and still requires cluster-admin rights for each deployment
  • Security-conscious deployments require RBAC policies set to absolute minimum.
  • This needs to work on other flavors of k8s than OpenShift

Disabling the admission controller is possible today with annotation cnpg.io/validation: "disabled", but the startup dependency still exists.

The behavior can be witnessed by deleting the webhooks, e.g ValidatingWebhookConfiguration, and then restart the operator pod. This makes the startup fail for the operator

The current rbac for admission registration is too permissive, which gives access to patch access to the webhook:

- apiGroups:
  - admissionregistration.k8s.io
  resources:
  - mutatingwebhookconfigurations
  - validatingwebhookconfigurations
  verbs:
  - get
  - patch

Describe the solution you'd like

I would like CNPG to be deployable without reequiring cluster-wide access from the k8 admin.
Make webhook dependency not part of the startup check currently enforced in ensurePKI(..) at startup.
The dependency can be controlled via deployment parameter so CNPG does not check webhook availability.

The cluster validation behavior can be achieved at reconcile time via plugins or by using the existing validation logic to make up for the lack of admission control. This would mean that if someone provides a faulty cluster spec, the reconciliation would fail and set a appropriate status.

The MutatingWebhook would need to be replaced with default values initialized by the operator itself. This can be done at the same phase as "SetDefaults" in reconcile(..) but with preserving the user parameters.

Healthprobes are currently being served over HTTPS on the webhook server. That could be changed to use the controller-runtime HTTP server. HTTPS is arguably not really needed as there's no client interaction with the operator. Having a separate webserver running in another thread serving HTTPS requests would be useless.

Describe alternatives you've considered

Adding cnpg.io/validation: "disabled" annotation to the cluster metadata does not make the webhooks optional. There's still a hard dependency on webhooks at startup. The dependency on webhooks makes CNPG not suitable for high security deployments where RBAC policy is set to a absolute minimum.

Additional context

Prometheus Operator, Cert-Manager and other operators have the webhooks optional and support fully namespaced deployment. I.e No ClusterRole needed.

Proposed split of PRs

The implementation can be split in 3 pull requests:

  1. a PR that makes the operator run without webhook dependency. The operator shall start up without crashing. It shall be capable of reconciling clusters without depending on webhooks.
  2. a PR that tests the operator can run without any cluster wide resource.
  3. a PR that adds validation in the reconciliation loop.

Backport?

No

Are you willing to actively contribute to this feature?

Yes

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. maxlengdell commented on Dec 12, 2025

    @maxlengdell
    ContributorAuthor

    This is the direction I imagine for the webhook dependency.
    maxlengdell@b15e47d
    Its just a WIP for now. But for the sake of discussion I add it here.

  2. armando1988 commented on Feb 10, 2026

    @armando1988

    Hello, I have a problem on this topic. I have limited scope on the cluster and cannot apply cluster-scoped resources. Has the feature for namespace-scoped deployment without deploying webhooks already been implemented and made available? If so, in which version?

    Thanks.

  3. GellertBabel commented on Feb 10, 2026

    @GellertBabel
    Contributor

    @armando1988 Hello, The namespace-scoped feature development is ongoing. We agreed that the implementation the PR will have more increments. And the first is just an option to deploy without the webhook dependency. For this I have just opened a PR, hopefully the direction can be approved soon, and we will be able to deploy CNPG without the webhooks.

  4. armando1988 commented on Feb 10, 2026

    @armando1988

    Hi @GellertBabel Thanks for the update!! :)

    So it’s still not known in which version the feature might be released.

    Regards

  5. maxlengdell commented on Feb 10, 2026

    @maxlengdell
    ContributorAuthor

    Hello @armando1988 , its not yet decided. Its currently in review within the maintainers group. If the namespaced solution would be of use to you, please leave a comment / thumbs up in the feature request: #9346 and this one. The more users that are interested in this direction, the better it is!

  6. armando1988 commented on Feb 10, 2026

    @armando1988

    @maxlengdell ok thanks!!

  7. armando1988 commented on May 8, 2026

    @armando1988

    Hello, there are any news to this topic?

  8. maxlengdell commented on May 11, 2026

    @maxlengdell
    ContributorAuthor

    Hello @armando1988 , this has not been approved by the maintainers yet, and will likely not be. There's a separate PR to support parallell admission controllers #10420 which would make possible to run parallell CNPG operators. That's not the intention with this PR, but would have been a implicit feature if this would go in. For CNPG to support deployment without webhook dependency it would require more discussion from other contributors I think

  9. dosubot commented on Aug 17, 2026

    @dosubot

    Hi, @maxlengdell. I'm Dosu, and I'm helping the cloudnative-pg team manage their backlog and am marking this issue as stale.

    Issue Summary

    Next Steps

    • If this is still relevant on the latest version of cloudnative-pg, please comment here to keep the discussion open.
    • Otherwise, this issue will be automatically closed in 7 days.

    Thanks for your understanding and contribution.

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

Metadata

Metadata

Assignees

Labels

Staletriage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions