Skip to content

cert-manager: add feature gate options for webhook and cainjector - #18787

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
KR-Ravindra:fix/cert-manager-webhook-feature-gates
Sep 11, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
KR-Ravindra:fix/cert-manager-webhook-feature-gates

Conversation

@KR-Ravindra

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Adds webhookFeatureGates and cainjectorFeatureGates to spec.certManager, so cert-manager feature gates can be set per component instead of only on the controller.

Problem

spec.certManager.featureGates is only rendered into the args of the cert-manager-controller container. The webhook and cainjector Deployments never receive --feature-gates, so gates that cert-manager documents as needing both the controller and the webhook (for example AdditionalCertificateOutputFormats or NameConstraints) are only half-applied: the controller supports the feature while the webhook refuses the resources that use it.

Root cause

upup/models/cloudup/resources/addons/certmanager.io/k8s-1.16.yaml.template:

  • line 13347: {{ range $key, $value := .CertManager.FeatureGates }} emits --feature-gates for the controller only
  • line 13448: the cert-manager-webhook container args have no feature gate handling
  • line 13248: the cert-manager-cainjector container args have no feature gate handling

The three cert-manager components accept different sets of gates (see the cert-manager feature-gates documentation, linked from docs/addons.md in this PR), so blindly copying featureGates to every container would not be correct either. The cert-manager Helm chart solves this with per-component values (featureGates, webhook.featureGates, cainjector.featureGates), which is the approach suggested in the issue discussion.

Fix

  • CertManagerConfig gains WebhookFeatureGates and CAInjectorFeatureGates (map[string]bool) in pkg/apis/kops, v1alpha2 and v1alpha3; conversion and deepcopy regenerated with make apimachinery-codegen, CRD regenerated with make crds.
  • The addon template renders the new maps into the webhook and cainjector container args, using the same range pattern as the controller. featureGates keeps applying to the controller only, so existing clusters are unchanged.
  • docs/addons.md documents the per-component gates.
  • The many-addons integration fixture sets both new fields and the golden output was regenerated with hack/update-expected.sh.

How tested

Golden update-cluster test (TestManyAddons), no cloud account needed.

Before the template change, with the fixture setting webhookFeatureGates / cainjectorFeatureGates and the expected webhook and cainjector args written into the golden file:

--- FAIL: TestManyAddons (0.49s)
    compare.go:81: diff:
        ...
                  - --v=2
                  - --leader-election-namespace=kube-system
        -         - --feature-gates=ServerSideApply=true
                  env:
                  - name: POD_NAMESPACE
        ...
                  - --dynamic-serving-dns-names=cert-manager-webhook.$(POD_NAMESPACE)
                  - --dynamic-serving-dns-names=cert-manager-webhook.$(POD_NAMESPACE).svc
        -         - --feature-gates=AdditionalCertificateOutputFormats=true
                  env:
        ...
    compare.go:85: output did not match expected for ".../many-addons/data/aws_s3_object_many-addons.example.com-addons-certmanager.io-k8s-1.16_content"
FAIL

After the template change:

=== RUN   TestManyAddons
--- PASS: TestManyAddons (0.46s)
PASS
ok  	k8s.io/kops/cmd/kops	0.519s

hack/update-expected.sh ./cmd/kops/ afterwards produced no further changes beyond the many-addons fixture (certmanager.io manifest, its manifestHash in the bootstrap addon list, and cluster-completed.spec). Also ran make apimachinery-codegen (no diff), go test ./pkg/apis/kops/..., go vet and go build ./cmd/kops/.

Links

Which issue(s) this PR fixes:

Fixes #17797

Special notes for your reviewer:

The kops_feature_table entry in the docs says 1.37; adjust if this lands in a different release. Gate names in the fixture (AdditionalCertificateOutputFormats for the webhook, ServerSideApply for the cainjector) are taken from cert-manager's webhook and cainjector feature lists.

This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.

The featureGates option only sets --feature-gates on the cert-manager
controller, so gates that cert-manager also requires on the webhook (for
example AdditionalCertificateOutputFormats or NameConstraints) were only
half-applied: the controller accepted the feature while the webhook
rejected the resources using it.

Following the cert-manager Helm chart, feature gates are now configured
per component. The new webhookFeatureGates and cainjectorFeatureGates
fields on certManager are rendered into the args of the webhook and
cainjector Deployments respectively; featureGates keeps applying to the
controller only, as before.
@kubernetes-prow kubernetes-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @KR-Ravindra!

It looks like this is your first PR to kubernetes/kops 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kops has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 9, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @KR-Ravindra. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 9, 2026
@kubernetes-prow
kubernetes-prow Bot requested a review from hakman September 9, 2026 09:48
@kubernetes-prow
kubernetes-prow Bot requested a review from olemarkus September 9, 2026 09:48
@KR-Ravindra

Copy link
Copy Markdown
Contributor Author

Round 1 self-review.

Re-checked against master: the two new maps are wired through kops, v1alpha2 and v1alpha3 with regenerated deepcopy, conversion and CRD, and the template uses the same range pattern as the existing controller featureGates, so flag ordering is deterministic and clusters that leave the fields unset render identically (only the many-addons fixture changes, by the two expected --feature-gates lines). This follows the per-component approach discussed in #17797 rather than copying the controller gates to every container, since the three components accept different gate sets.

The docs table says 1.37, matching KOPS_RELEASE_VERSION on master today; if this should land as 1.38 because release-1.37 is already cut, I will change it.

Marking ready for review.

@KR-Ravindra
KR-Ravindra marked this pull request as ready for review September 9, 2026 09:55
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2026
@hakman

hakman commented Sep 9, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 9, 2026
@KR-Ravindra

Copy link
Copy Markdown
Contributor Author

/retest

The gce-cilium failure was a sum.golang.org stream error while ko verified a module during the kops-controller image build, before any cluster was created.

@hakman

hakman commented Sep 9, 2026

Copy link
Copy Markdown
Member

/retest

@KR-Ravindra

Copy link
Copy Markdown
Contributor Author

The second pull-kops-e2e-k8s-gce-ipalias run failed the same way as the first: sum.golang.org/tile/8/0/x141/455: stream error while ko verified go-jose/v4 during the kops-controller image build, before any cluster was created. Job history shows the same job green on 13 of the last 20 runs, so retrying once more.

/test pull-kops-e2e-k8s-gce-ipalias

@KR-Ravindra

Copy link
Copy Markdown
Contributor Author

/test pull-kops-e2e-k8s-gce-cilium

@hakman

hakman commented Sep 11, 2026

Copy link
Copy Markdown
Member

Thanks for this @KR-Ravindra (and your AI).
/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 11, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 11, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit cfd0b7f into kubernetes:master Sep 11, 2026
29 checks passed
kubernetes-prow Bot added a commit that referenced this pull request Sep 11, 2026
…-upstream-release-1.37

Automated cherry pick of #18787: cert-manager: add feature gate options for webhook and cainjector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/addons area/api area/documentation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cert-manager: feature gates are not applied to webhook

2 participants