Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jakexks 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 |
9c22449 to
6bd72c0
Compare
This commit lays the groundwork for supporting multiple shims - Ingress specific code has been replace with more generic runtime.Object or metav1.Object code. Signed-off-by: Jake Sanders <[email protected]>
7497d0b to
56d484b
Compare
| IngressShimOptions: controller.IngressShimOptions{ | ||
| CertificateShimOptions: controller.CertificateShimOptions{ |
There was a problem hiding this comment.
I remember hearing that "ingress shim" was not an appropriate name and that "certificate shim" made more sense. Could you document that somewhere? E.g. in the website since end-users may also wonder why we are calling it that 😅
There was a problem hiding this comment.
Yes, after the feedback from the last retro this should not be merged without a matching PR to the documentation
Signed-off-by: Jake Sanders <[email protected]>
Signed-off-by: Jake Sanders <[email protected]>
Signed-off-by: Jake Sanders <[email protected]>
56d484b to
b25469c
Compare
Signed-off-by: Jake Sanders <[email protected]>
| if l.TLS.CertificateRef.Group != "core" { | ||
| errs = append( | ||
| errs, | ||
| fmt.Errorf( | ||
| "unsupported certificateRef.group, want %s got %s", | ||
| "core", | ||
| l.TLS.CertificateRef.Group, | ||
| ), | ||
| ) | ||
| } |
There was a problem hiding this comment.
question: should we also look at the TLS block on the HTTPRoute? From this thread:
There was a problem hiding this comment.
👍 I will have to comb over the semantics of gateways and routes and then write a bunch of tests
| func (c *controller) validateObject(obj metav1.Object) []error { | ||
| switch o := obj.(type) { | ||
| case *networkingv1beta1.Ingress: | ||
| // check for duplicate values of networkingv1beta1.IngressTLS.SecretName |
There was a problem hiding this comment.
question: why do we need to bail out when two TLS blocks contain the same secretName? I can't figure that out (apologies for commenting on old code!)
|
|
||
| func (c *controller) Sync(ctx context.Context, ing *networkingv1beta1.Ingress) error { | ||
| log := logf.WithResource(logf.FromContext(ctx), ing) | ||
| func (c *controller) Sync(ctx context.Context, obj runtime.Object) error { |
There was a problem hiding this comment.
This reconciliation function focuses on multiple object types (Ingress + Gateway + HTTPRoute in the future).
The positive side is that we get a bit of code deduplication.
On the negative side, we are making things blurrier for the reader due to having another level of indirection (i.e., the new "generic lister").
I might be missing something: why not have a separate Sync function for each kind (Ingress, Gateway, and soon HTTPRoute)? Is it too costly in terms of boilerplate?
There was a problem hiding this comment.
A couple of thoughts from me: It's written with the future in mind (this could help with supporting multiple ingress versions at once). Also most of the functionality is the same (reading the annotations), the only difference is parsing the reference to TLS secrets
There was a problem hiding this comment.
For what it's worth, I started this WIP by writing duplicate functions and I thought it was worse.
There was a problem hiding this comment.
Could we adjust this to be two distinct controllers, but where there is duplicate logic, factor that into standalone library functions instead? This will be easier to maintain long term, including when/if we ever create alternate ingress-shim's too (rather than having to constantly add more complex switching logic into this one controller)
There was a problem hiding this comment.
I started working on this idea. As a first step, I opened #4149
Signed-off-by: Jake Sanders <[email protected]>
jakexks
left a comment
There was a problem hiding this comment.
Some of my own thoughts
| protobuf_deps() | ||
|
|
||
| ## Load rules_go and dependencies | ||
| ## Load rules_go and dependencies |
There was a problem hiding this comment.
This replaces a unicode non breaking space with a normal space
| --set installCRDs=true \ | ||
| --set featureGates="${FEATURE_GATES:-}" \ | ||
| --set "extraArgs={--dns01-recursive-nameservers=${SERVICE_IP_PREFIX}.16:53,--dns01-recursive-nameservers-only=true}" \ | ||
| --set "extraArgs={--dns01-recursive-nameservers=${SERVICE_IP_PREFIX}.16:53,--dns01-recursive-nameservers-only=true,--controllers=*,--controllers=gateway-shim}" \ |
There was a problem hiding this comment.
As Gateway-shim is disabled by default, enable it here
| check_tool kubectl | ||
| check_tool kustomize | ||
|
|
||
| kustomize build "github.com/kubernetes-sigs/gateway-api/config/crd?ref=$GATEWAY_API_VERSION" | \ |
There was a problem hiding this comment.
I tried for half an hour to get this with an http_archive to make the build more bazel like but gave up
| gatewaylisters "sigs.k8s.io/gateway-api/pkg/client/listers/apis/v1alpha1" | ||
| ) | ||
|
|
||
| // objectLister is the most minimal generic lister. |
There was a problem hiding this comment.
This isn't very nice. But I couldn't think of anything better
There was a problem hiding this comment.
After thinking about lister.go, I could not think of any other way.
I thought about injecting Get() metav1.Object and List() []metav1.Object but in the end the code would be very similar with what you have written in lister.go.
I approve lister.go!
JoshVanL
left a comment
There was a problem hiding this comment.
Looks good to me :) small comment from me.
Have we ensured we have changed the wording throughout the codebase and website?
I assume we want to keep the idea of "ingress-shim", but how about in the code?
I did a minimal pass through the code but will be a bit more thorough as this evolves. Before this PR is merged we will need a matching documentation PR to the website's release-next branch.
I think the idea should be renamed to certificate-shim. However there are ingress specific annotations such as the edit-in-place one, so there will have to be documentation for both ingresses and gateways making the differences clear. |
Signed-off-by: Jake Sanders <[email protected]>
|
/milestone v1.5 |
|
/kind feature |
|
I've not had a proper review of this, but I feel like this would be a lot easier to maintain if we don't try and slam two different controllers into one. It is surprising to me that adding support for Gateway resources has involved touching so much of the existing ingress-shim code, and it makes this PR feel riskier to merge (as there's a whole load of well-used existing code that is being touched/reworked). |
|
I think having a standalone one (with perhaps some shared library bits where it makes sense, e.g. for parsing annotations) will make it easier to support nuances of the two different API types in future. |
|
Happy to make it separate controllers. I started this PR by doing that but felt that most of the functionality was duplicated. A library approach would also work fine. A certificate-shim controller:
It was mostly replacing the type signature of a function that took a |
|
Couple of thoughts after doing something else for a day:
|
|
@jakexks: PR needs rebase. DetailsInstructions 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/test-infra repository. |
|
Should we close this PR in favor of #4158? |

What this PR does / why we need it: cert-manager aims to make issuing ACME certificates for public endpoints as painless as possible. A popular use-case is to annotate ingress definitions, which cert-manager's ingress-shim uses to create Certificates automatically.
As part of #4118, we aim to add support for the sig-network community's Gateway API as a way to solve http-01 challenges. cert-manager should be able to read annotations from Gateways and turn these into Certificates just as it currently can with Ingresses
Which issue this PR fixes: Fixes #4119
Special notes for your reviewer:
the
sync.godiff has become large enough that Github hides it by default.Release note: