Repository navigation
Implement the Gateway API shim ("gateway-shim" controller) - #4158
Conversation
81393de to
7d63d34
Compare
95a61e2 to
05f6017
Compare
55b230f to
8de3c60
Compare
59d7fda to
06febbe
Compare
f03388a to
4de31bf
Compare
4de31bf to
d855ea2
Compare
Signed-off-by: Maël Valais <[email protected]>
c2af666 to
ecaf9ba
Compare
Signed-off-by: Maël Valais <[email protected]>
Note that the gateway-shim is only half the work for supporting the Gateway API in cert-manager. The other half is the HTTP01 solver support, which is still worked on. The Gateway API in cert-manager is releases as an experimental feature and needs to be enabled manually with the following flag: --controllers=*,gateway-shim All the annotations supported by ingress-shim are also supported by gateway-shim, with some exceptions: "acme.cert-manager.io/http01-ingress-class" This annotation is not supported on the Gateway resource. Although the Gateway resource also has a "gatewayClass" field, we will need to add another field instead of "ingress-class" to avoid confusion with the ingress-shim. "acme.cert-manager.io/http01-edit-in-place" This annotation is not supported because it is specific to some ingress controllers like ingress-gce. "kubernetes.io/tls-acme" This annotation is not supported because it is a behavior inherited from kube-lego and we chose not to keep this behavior with the Gateway API. Unlike the ingress-shim, you can reuse the same Secret name in multiple TLS configurations on the same Gateway resource. The ingress-shim now shows the exact location of the duplicate secretName when the user gives the same secretName in two separate TLS blocks. Signed-off-by: Maël Valais <[email protected]> Co-authored-by: Jake Sanders <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
The Gateway CRD has to be installed, meaning that the CRDs may be installed after cert-manager. We don't want cert-manager to crash in that case; instead, we let the user know that cert-manager will keep retrying looking for the CRDs with this message on startup: controller.go:181] cert-manager/controller/build-context "msg"="the Gateway API CRDs do not seem to be present, cert-manager will keep retrying watching for them" The user then sees the following message printed (using an exponential back-off): reflector.go:167: Failed to watch *v1alpha1.Gateway: failed to list *v1alpha1.Gateway: the server could not find the requested resource (get gateways.networking.x-k8s.io) Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
ecaf9ba to
368c765
Compare
|
This looks good to me - glad we'll have support for the Gateway API now! I'm adding an lgm with a hold - I see that the PR is still 'WIP', but I guess the last item is not strictly related to this code as such. /test pull-cert-manager-e2e-v1-21 /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irbekrm, maelvls The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold 🔥 |
|
🥳 🥳 seems like a good time for an alpha release? |
In #4121, Jake implemented the support for the Gateway object for the "ingress shim" mechanism proposed as described in #4119. Jake decided to rename "ingress shim" to "certificate shim" the object that we create that that serves as a "shim" for bootstrapping the Secrets inside the TLS block of an Ingress.
This PR refactors the new "certificate shim" to be two separate controllers instead of a single one, as proposed by @munnerz:
Tasks:
issuerRef(tbd @maelvls)sync_test.gocert-manager-devandcert-managerandsig-gateway-apiArchived discussion: from "everything in the `controller` struct" to `SyncFnFor`
Instead of using a single struct, I use simple functions that clearly define their dependency. I want to avoid the "struct bloat" that makes it really hard to comprehend what is depending on what.
Instead of relying on a bloated
controllerstruct, the commonSyncinjects its dependencies. The only caveat is that the number of arguments forSyncis quite big:Pros:
controllerstruct bloat where we don't know which field is used where.Cons:
controllerstruct that makes it really hard to know what is depending on what),Syncis indented twice.Important notes for the reader
I removed the
ClusterIssuerandIssuerinformers that were in thecontrollersince (1) they were not used, and (2) no event handler was set up. I think these were copy-pasted from another controller and we forgot to remove them. As you can see in the old controller.go, no event handler was set:I changed the way the logs are injected, which may change the way logs "look like" (e.g., I have to check whether the name of the controller still shows).
Before,
c.logwas configured with the controller name, but the actualSyncfunction was not usingc.log:After, we don't use
logf.FromContextanymore and just pass the logger as an argument toSyncFnFor.Test it!
Make sure you are running cert-manager with the flag
--controllers=*,gateway-shim(the gateway shim controller is disabled by default) and that you have installed the Gateway API CRDs. To setup both:Then, create a Gateway. The issuer
foodoes not have to exist:You should now see a Certificate named
example-com-tls:/kind feature