Conversation
|
@squakez this is the fix, there are two assumptions i should say that i have taken while building this written above too but writing it here so you can deal a good focus on it:
|
squakez
left a comment
There was a problem hiding this comment.
Thanks for the work. It's a good ground we can use to reason about the feature. The logic seems to be fine overall, beside a few optimization. However there are important design decision we need to take to make it more performant and reliable. See each comment and we can add more information in each thread.
| // secret name. It may fall back to t.Host so that auto-discovery also works for the | ||
| // common single-host case, without changing the pre-existing manual TLS behavior | ||
| // (which requires TLSHosts to be set explicitly and never considers t.Host). | ||
| if secretName == "" { |
There was a problem hiding this comment.
I think we miss a check on the auto parameter. If disabled on purpose, we should not proceed. Ideally the check has to be done in the Configure. And in fact, you can use in general the Configure func to compute any configuration that you will later use in Apply by storing private scoped variables.
…on of concerns clear among configure and apply
|
✔️ Unit test coverage report - coverage increased from 63.8% to 64% (+0.2%) |
…nabled by default and added a function to disable it
…e test client, matching the Knative default, and exclude cert-manager duck types from the generic fake Kubernetes clientset (they are only ever accessed via the typed controller-runtime client).added types to prevent unstructured, ingress_test made it enabled by default and added a function to disable it
|
@squakez thanks for the compehensive comment going carefully through this code, after your comments i decided that a seperation of concerns was a must thereby seperating into configure and apply as would be visible and seconly tookl up on your untyped fileds and followed the example elsewhere shown in this repo, thirdly the very last one i should say i have followed up on your advice, downside being cert-manager detection static for the operator's lifetime if someone installs cert-manager into a running cluster, the operator won't notice until it restarts. |
This is certainly a side effect that we can document. We have a similar "problem" with Knative and it's documented as well. |
|
@squakez mirroring the knative's approach i have added the required docs |
squakez
left a comment
There was a problem hiding this comment.
Nice. Only a minor check on a potential bootstrap error, but the rest LGTM.
|
✔️ Unit test coverage report - coverage increased from 63.8% to 63.9% (+0.1%) |
…orced-issuer branch of resolveCertManagerIssuer() into its own resolveForcedCertManagerIssuer() method to bring nesting complexity under golangci-lint's nestif threshold, and switch to plain (unnamed) return values to satisfy nonamedreturns.
|
✔️ Unit test coverage report - coverage increased from 63.8% to 63.9% (+0.1%) |
|
@squakez i have also fixed the issue that were failing some checks |
Summary
Adds cert-manager auto-discovery to the Ingress trait. When enabled, Camel K detects whether cert-manager is installed, resolves a
ClusterIssuerorIssuer(either forced by name or auto-discovered), and annotates the generated Ingress so cert-manager's own ingress-shim handles certificate issuance and renewal.Camel K never creates
Certificateresources itself — this keeps certificate lifecycle management entirely inside cert-manager, where it belongs.Fixes #5857
New Trait Options
tls-cert-manager-auto— enable cert-manager auto-discoverytls-issuer-name— force a specific issuer, bypassing auto-discoverytls-issuer-kind—IssuerorClusterIssuer(defaults toClusterIssuer)Design Notes / Tradeoffs for Reviewers
Multiple issuers: When auto-discovery finds more than one
ClusterIssuer/Issuer, the first one is selected rather than requiring exactly one unambiguous match. This was chosen for simplicity over correctness-by-refusal. Happy to switch to an "only when exactly one issuer is found" behavior if reviewers prefer.t.Hostfallback: The cert-manager path also activates when onlyingress.hostis set. This is intentional becauseingress.hostis the field most users actually configure. This fallback is scoped strictly to the cert-manager path (only whentlsSecretNameis empty) and does not change the existing manual-TLS behavior covered byTestConfigureTLSWithoutHostsIngressTraitDoesSucceed.RBAC widening: Adds
get/list/watchpermissions forissuersandclusterissuers(cert-manager.io) to the operator'sClusterRole/Role. These permissions are read-only.clusterissuersare cluster-scoped even in the namespaced installation mode; this is flagged for review against the project's RBAC threat model.E2E scope: Rather than performing a live HTTPS round-trip through a real ingress controller—which would require additional infrastructure such as DNS, a tunnel, or an ingress addon—the E2E test verifies the issued certificate cryptographically. It parses the TLS secret and checks the DNS SAN and certificate expiry after confirming that cert-manager populated it.
Implementation
pkg/util/certmanager/— new cert-manager detection package (IsInstalled,ListClusterIssuers,GetClusterIssuer,GetIssuer), built onunstructuredwithout introducing a cert-manager Go client dependency. Absence of cert-manager degrades cleanly to "not found" rather than returning an error.pkg/trait/ingress.go— addsresolveCertManagerIssuer()and reworks the TLS block inApply()to merge the manual-TLS and cert-manager paths.RBAC: Adds the required
ClusterRole/Role/RoleBindingpermissions forissuersandclusterissuers.e2e/cert-manager/— new cert-manager E2E workflow with its own Makefile target, mirroring the structure of the existinge2e/gatewaysuite.Test Plan
Unit tests:
pkg/util/certmanager— 8 tests covering installation detection and all three "absent" failure modesUnit tests:
pkg/trait/ingress_test.go— 6 additional tests covering:Existing Ingress trait tests — 12 tests pass unmodified, confirming no regression to manual TLS behavior
go build ./...gofmt./script/check_licenses.shE2E suite (
make test-e2e) — not run in this environment; reviewers/CI to confirm🤖 Generated with Claude Code on behalf of Thundercloud12