Repository navigation
Experimental Gateway API support for ACME HTTP-01 Solving - #4276
Conversation
|
Should this be implemented in a similar manner to how we expect Istio's VirtualService solving to be implemented? (i.e. out of tree) - given that the Gateway API is likely to be added as a set of CRDs, and is still in the alpha stages, I feel like it may be a little unfair on the Istio case if this were merged into our core-codebase (and sort of opens up floodgates for more implementations afterwards). From my understanding, the gateway API will not supersede Istio's VirtualService in future either, though I may be wrong :) |
|
We don't expect to support Istio VirtualService ever! This feature came out of the research into out-of-tree HTTP01 solving. It seems that the wider cloud-native community is coalescing around the Gateway API (in addition to their own APIs), and is already gaining wide adoption even in the alpha form: https://gateway-api.sigs.k8s.io/references/implementations/ . We talked about it amongst the team and decided that having support for this one CRD in-tree would be better that supporting individual solutions. While it will never expose all the features of each service mesh or API router, the primitives are suitable enough for routing HTTP01 challenges, and this will be enough for people using any of the various implementations to be able to use cert-manager's ACME solver. The alternative is making a pluggable HTTP-01 API and implementing this there. I think cert-manager is due a big refactor where all controllers become plugins and you could then pick and choose which features you want in your binary like Caddy, but that's for a future discussion |
irbekrm
left a comment
There was a problem hiding this comment.
This looks really good to me!
Mostly interested if users will be ok with having to have a listener block for port 80 on the Gateway for the ACME challenge. I wonder if it may not be nice if that part too was done by cert-manager and maybe if it could be not permanent.
Just to consider alternatives, do you think it might make sense for cert-manager to modify the Gateway as well as creating the HTTPRoute or even allow for optionally creating a temp Gateway for this?
I was experimenting with deploying this with Contour, but got an error in the logs, but I guess that's expected since this is WIP
E0730 07:19:52.246505 1 sync.go:185] cert-manager/controller/challenges "msg"="propagation check failed" "error"="not implemented" "dnsName"="kuard.irbe-krumina-gcp.jetstacker.net" "resource_kind"="Challenge" "resource_name"="cm-test-ffx6l-425789567-139583572" "resource_namespace"="projectcontour" "resource_version"="v1" "type"="HTTP-01"
| class: | ||
| description: The Gateway class to use when creating HTTPRoute resources to solve ACME challenges that use this challenge solver. | ||
| type: string | ||
| labels: |
There was a problem hiding this comment.
Suggestion: also mark this field as required, so that it appears as such when running kubectl explain, like here
There was a problem hiding this comment.
I think you literally add it to the deploy/crds/crd-challenges.yaml file. Not whole of it is auto-generated (I think)
I'm not sure. I feel like it's the responsibility of the cluster administrator to setup the Gateways and users can just use HTTPRoutes, which makes me feel like we should not mutate the Gateway and this way is cleaner. |
|
My self review is a worry about the cert-manager API. We know that the gateway API is evolving and the field will not be stable. Is it OK to have a cert-manager.io/v1 resource not be compatible with a future cert-manager.io/v1 resource, as long as we make it very clear to users of the gateway API that this is experimental? |
|
idr, if we these were ran already /test pull-cert-manager-e2e-v1-22 |
|
/test pull-cert-manager-e2e-v1-17 Just in case |
irbekrm
left a comment
There was a problem hiding this comment.
I've tested this e2e with Contour and seems to work nicely 🥳
My self review is a worry about the cert-manager API. We know that the gateway API is evolving and the field will not be stable. Is it OK to have a cert-manager.io/v1 resource not be compatible with a future cert-manager.io/v1 resource, as long as we make it very clear to users of the gateway API that this is experimental?
I guess the Kubernetes-native way would be to create an alpha CRD version for our Issuer type?
Looking at some implementations of Gateway API where it's integrated into the standard config, I see that it is sometimes marked as 'experimental', see i.e Traefik's configuration here and I'm also getting more convinced that we need to give some stronger indication of it being experimental.
I still think that adding a field named 'experimental..' that will later be deprecated is not much better than adding a field whose behaviour may change.
Maybe marking the issuer.spec.acme.solvers.http01.gateway as in '[Experimental]' in the description and also adding to the description which particular version of Gateway API it supports would be sufficient?
|
|
||
| // Gateway contains configuration for the Gateway API controller | ||
| // being used during HTTP-01 tests. | ||
| Gateway Gateway |
There was a problem hiding this comment.
Nit/Suggestion: either call this GatewayController or rename the one above to Ingress
It feels like because cert-manager syncs |
| switch { | ||
| case apierrors.IsNotFound(err): | ||
| gatewayAvailable = false | ||
| log.Info("the Gateway API CRDs do not seem to be present, cert-manager will keep retrying watching for them") |
There was a problem hiding this comment.
I need to restart cert-manager to get the Gateway API solver/shim to work, right?
Is it still going to complain about the reflector not being able to list *v1alpha1.Gateway even though gatewayAvailable = false?
Maybe we should write that in the documentation: a listener on port 80 is required, and we advise using a dedicated label meant for the HTTPRoutes that will be created: apiVersion: networking.x-k8s.io/v1alpha1
kind: Gateway
metadata:
name: example-traefik
annotations:
cert-manager.io/issuer: letsencrypt-traefik
spec:
gatewayClassName: traefik
listeners:
- protocol: HTTP
port: 80
routes:
kind: HTTPRoute
selector:
matchLabels:
gateway: http01-solver-traefik # 🔥 Dedicated to HTTPRoutes for challenges.
namespaces:
from: AllOr maybe people don't need to bother with a separate port 80 listener... Most importantly, we shall send an event on the Issuer to notify the user that this issuer may not work due to the labels given not being compatible with one of the port 80 listeners. For the ingress HTTP-01 solver, the ingress controller must also be configured "by the operator" to accept connections on port 80 (cert-manager is not able to "temporarily" add port 80 to the proxy's configuration since it doesn't know how to configure proxies) |
I am also worried about this. Currently, the Gateway API is at With an kind: Issuer
spec:
acme:
solvers:
- http01:
# Everything under this field may be removed or changed in the future,
# and the only supported Gateway API version is `v1alpha1`.
experimental:
httpRoute:
labels:
gateway: example-haproxy
After all, since our API surface seems quite small, maybe we don't need to worry that much about |
|
These all should pass now /test pull-cert-manager-e2e-v1-22 |
Signed-off-by: Jake Sanders <[email protected]>
There was a problem hiding this comment.
🎉🎉
To close the above discussions, here is what we went with:
Gateway shim
- To be able to use the gateway shim feature, users have to pass
--controllers=*,gateway-shim. - When cert-manager is started with the gateway shim feature turned on but the Gateway API CRDs are not yet installed, the user will be warned that the CRD should be installed.
- The user can install the CRD after starting cert-manager, and cert-manager will pick it up.
Gateway HTTP-01 solver
- To be able to use the gateway solver, users need to install the Gateway API CRDs,
- When cert-manager is started without the CRDs installed, cert-manager says that the Gateway HTTP-01 solver support is disabled due to the CRDs no being installed,
- In order to install the CRDs after cert-manager is running, you have to restart cert-manager.
Name of the field in the Issuer, Gateway API breaking the Issuer API
In previous discussion, we had talked about nesting the Gateway API solver configuration on the Issuer under an experimental field, but we did not go with this idea. Instead, the API documentation says [Experimental]. The Issuer configuration looks like this:
kind: Issuer
spec:
acme:
solvers:
- http01:
gatewayHTTPRoute:
ServiceType: ClusterIP
labels:
gateway: example-haproxy
# We decided not to add "podTemplate".The podTemplate field was not added, I'll link the discussion TBD
/lgtm
/hold
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jakexks, 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 |
Signed-off-by: Jake Sanders <[email protected]>
|
/test pull-cert-manager-e2e-v1-16 |
Signed-off-by: Jake Sanders <[email protected]>
|
/lgtm |
Signed-off-by: Jake Sanders <[email protected]>
|
/test pull-cert-manager-e2e-v1-16 |
|
/test pull-cert-manager-e2e-v1-16 "Pod got deleted unexpectedly" 😖 |
|
Probably a flake /test pull-cert-manager-bazel |
|
/lgtm |
|
/hold cancel |
What this PR does / why we need it:
The cert-manager ACME HTTP01 solver currently uses Ingress to solve incoming challenges. Although Ingress is widely used, many people prefer to use different API Gateways or service meshes to route traffic to their cluster; users have been asking for support of Istio VirtualService and Gloo VirtualService.
The sig-network Gateway API aims to provide a common set of CRDs that can be implemented by various controllers. By supporting these common CRDs in cert-manager, users should now be able to solve ACME HTTP01 challenges with their preferred solution.
This PR adds a new field to the
ACMESolversection ofIssuers orClusterIssuers which will tell cert-manager to create Gateway APIHTTPRouteswith user-supplied labels. Implementations of the gateway API can look at these HTTPRoutes to solve challenges:Example Gateway configuration using HAProxy: (click to expand)
Example Issuer configuration:
Note that the Gateway API is in its alpha stage. This means the stability of the gateway solver field is not guaranteed.
Which issue this PR fixes :
Fixes #4118
Special notes for your reviewer:
Release note:
/kind feature