Skip to content

feat(ingress-controller): issue the webhook certificate with cert-manager - #1050

Open
cvas22 wants to merge 1 commit into
apache:masterfrom
cvas22:feat/993-webhook-cert-manager
Open

cvas22 wants to merge 1 commit into
apache:masterfrom
cvas22:feat/993-webhook-cert-manager

Conversation

@cvas22

@cvas22 cvas22 commented Nov 17, 2026 •

Copy link
Copy Markdown

Refs #993

The ingress controller chart generates the webhook CA and cert with genCA/genSignedCert and relies on lookup to keep the live ones. Argo CD renders offline, so lookup returns nothing and every comparison wants a new Secret and caBundle. The app never settles and an automated sync rotates the webhook trust chain.

This adds the cert-manager path suggested in the issue:

webhook:
  certManager:
    enabled: true
    # issuerRef: {name: my-ca, kind: ClusterIssuer}   # optional, self-signed Issuer otherwise
    # duration: 8760h

When it's on, the chart renders a Certificate for the webhook service (writing into the same secret name the deployment already mounts), a self-signed Issuer unless issuerRef is set, adds cert-manager.io/inject-ca-from to the ValidatingWebhookConfiguration and leaves caBundle out so the cainjector fills it. Nothing is generated at render time, so two helm template runs with the same input give identical output. Combining it with certificate.provided fails with a clear message. With it off (the default) nothing changes.

Notes

I checked it with helm template: the default render is the same as before, two renders with certManager.enabled=true hash the same, there's no caBundle in that mode, the custom issuerRef drops the self-signed Issuer, and enabling both options fails. Bumped the chart to 1.5.0 since it's a new option and added the README rows the way helm-docs lays them out. I didn't run it against a live cluster with cert-manager, so a second pair of eyes there would be nice.

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding a deterministic opt-in path, @cvas22! I rendered this branch twice with webhook.certManager.enabled=true: the output is identical, no chart-managed Secret is rendered, and caBundle is left to cainjector. The Certificate and inject-ca-from names also line up.

A few changes are needed before merging:

  1. Give the default SelfSigned Certificate a non-empty subject or commonName. cert-manager's SelfSigned documentation warns about an empty Issuer DN and BadConfig events.
  2. Handle upgrades where old coalesced values do not contain webhook.certManager, such as --reuse-values. Removing that new map to simulate the old defaults currently causes a nil-pointer error.
  3. Add committed render tests for repeatability and the new modes, plus live cert-manager/cainjector coverage for issuance, CA injection, renewal, and upgrade.
  4. Rebase and update the chart version from the already-released 1.5.0.

Since the default certManager.enabled=false path still generates random certificates, please use Refs #993 or Partially addresses #993 rather than closing that issue automatically. This is a valuable opt-in improvement; the default-path follow-up can remain tracked separately. Thanks again!

@cvas22
cvas22 force-pushed the feat/993-webhook-cert-manager branch from 6647799 to 72ef855 Compare November 23, 2026 03:56
@cvas22

cvas22 commented Nov 23, 2026

Copy link
Copy Markdown
Author

Pushed 72ef855: the Certificate now has a commonName, the template copes with values that have no webhook.certManager (the --reuse-values case), I rebased and bumped the chart to 1.6.0, and the PR now says Refs #993. I also added render tests and an e2e script with cert-manager in kind (issuance, CA injection, renewal, upgrade from 1.5.0) plus a CI job. The render tests pass locally, but I couldn't run the e2e one here, so CI will be its first run. thx

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick follow-up, @cvas22! The commonName, missing-values handling, chart version, and PR scope now look good. I ran the render suite through bash: all 31 checks passed.

I found a few issues in the new CI/E2E path that we should fix before running it:

  1. Both new shell scripts have mode 100644, while the workflow invokes them directly. Please mark them executable, or invoke them with bash, to avoid Permission denied.
  2. The second release reuses the cluster-scoped IngressClass/apisix created by the first release. Helm will reject the second installation because of ownership metadata. Please give the upgrade release its own class, for example --set config.kubernetes.ingressClass=apisix-upgrade, and preserve it during the subsequent upgrades.
  3. The normal Helm upgrade at test/e2e/webhook-cert-manager.sh is not wrapped in check, and the script does not use set -e. If that upgrade fails, the unchanged serial and CA checks can still pass. Please assert that the upgrade itself succeeds before checking those invariants.

Two smaller cleanup items: use fixed release names in the cleanup trap so the first release is not left behind, and consider a short stable commonName such as apisix-ingress-webhook; the full Service DNS names are already in dnsNames, while a long FQDN can exceed the recommended commonName length.

Once those are fixed, we can run the full Helm 3/4 and cert-manager E2E matrix. Thanks again for adding this coverage!

…ager

The chart generates the webhook CA and certificate with genCA/genSignedCert
and keeps the live ones with lookup. Tools that render offline, like Argo CD,
can't run lookup, so every render produced new certificates and a new
caBundle, leaving the app OutOfSync and rotating the webhook trust chain on
each automated sync.

Add webhook.certManager. When enabled the chart renders a cert-manager
Certificate (and a self-signed Issuer unless issuerRef is set), annotates
the ValidatingWebhookConfiguration with cert-manager.io/inject-ca-from and
leaves caBundle to the cainjector, so repeated renders are identical. It
can't be combined with certificate.provided. Default behavior is unchanged.

Refs apache#993

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 force-pushed the feat/993-webhook-cert-manager branch from 72ef855 to fe52959 Compare November 23, 2026 05:44
@cvas22

cvas22 commented Nov 23, 2026

Copy link
Copy Markdown
Author

Fixed in fe52959: both scripts are executable now, the upgrade release has its own ingress class (apisix-upgrade), the plain helm upgrade is wrapped in a check, the cleanup uses fixed release names, and the commonName is now apisix-ingress-webhook. Render tests still pass, the e2e one hasn't run yet. thx

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick fixes, @cvas22! The full CI matrix is green on fe52959. Both Helm 3.22.1 and 4.2.4 passed all 31 render checks and all 15 live cert-manager E2E checks, including issuance, CA injection, renewal, normal upgrade, and migration from chart 1.5.0. I also verified the final render suite locally. Approving.

@moonming
moonming requested a review from membphis November 24, 2026 02:53

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants