Repository navigation
Allow ingressClass to be specified for ingress-shim - #454
bbetter173 wants to merge 13 commits into
Conversation
…le the use of ingressClass: <value>
|
@HeWhoWas: Adding do-not-merge/release-note-label-needed because the release note process has not been followed. DetailsOne of the following labels is required "release-note", "release-note-action-required", or "release-note-none". Instructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Assign the PR to them by writing 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 |
|
Thanks for this PR! So given we actually know the ingress class for a particular ingress already, I'm not sure we need to allow the user to specify a custom ingress class to be used. Instead, we could introduce a If this annotation is not set to "true": set the ingress class field to that of the Ingress being processed What do you think? I'm not certain exposing the ingress class field in its entirety is required. ingress-shim is meant to provide a 'user friendly' abstraction to make things easy in 9/10 usecases, and if a user needs some advanced functionality they can fall back to creating the Certificate themselves. |
| * ``certmanager.k8s.io/ingress-class: ""`` - by default, if the | ||
| 'kubernetes.io/tls-acme' annotation is set to "True", the resulting Certificate | ||
| is created with 'ingest: <name>' in the acme spec. If present, this annotation | ||
| will alter this behaviour and supply 'ingestClass: <value>' when creating the |
| specified as arguments to the ingress-shim container. | ||
|
|
||
| * ``certmanager.k8s.io/ingress-class: ""`` - by default, if the | ||
| 'kubernetes.io/tls-acme' annotation is set to "True", the resulting Certificate |
True.
Sounds good! |
…houldSync() and relevant test.
| } else { | ||
| ingressClass, ok := ingAnnotations["kubernetes.io/ingress.class"] | ||
| if !ok { | ||
| return fmt.Errorf("unable to determine class of ingress %s", ing.Name) |
There was a problem hiding this comment.
I'm not sure we should error here - according to the ingress spec, it is valid to have a ingress without a class. In this instance, all ingress controllers will act on the ingress resource.
Right now, if a user does not specify ingress or ingressClass on the Certificate resource, an ingress will be created that does not specify ingress class. We should probably do the same here too (i.e. if edit-in-place is not specified, and ingress class isn't specified, just leave the ingress/ingressClass fields blank)
| tlsACMEAnnotation = "kubernetes.io/tls-acme" | ||
| // editInPlaceAnnotation is used to toggle the use of ingressClass instead | ||
| // of ingress on the created Certificate resource | ||
| editInPlaceAnnotation = "certmanager.k8s.io/edit-in-place" |
There was a problem hiding this comment.
We should probably prefix this with acme-http01 to bring it in-line with other annotations, e.g. certmanager.k8s.io/acme-http01-edit-in-place. It's quite wordy, but it is more specific (and I'd hope more obvious to the user what it is for?)
…hout setting either ingress or ingressClass.
| set to http01, and the ingress has the 'kubernetes.io/tls-acme: true' | ||
| annotation, this controls whether the ingress is modified 'in-place', or a new | ||
| one created specifically for the http01 challenge. Must be 'true' or 'false'. | ||
| Defaults to 'false' |
There was a problem hiding this comment.
Perhaps worth noting that any value other than 'true' is classed as 'false'
…order to make use case more obvious and have consistent naming.
|
Can you also fix unit tests and add a new unit test for this functionality? It should be clear how from the contents of sync_test.go 😄 /ok-to-test |
|
@HeWhoWas: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
|
@munnerz - This is where I start to fall down a little bit, I'm not sure why the tests are failing and it's not totally obvious to me how to add more unit tests, sorry. I'm happy to learn, but I'll need a bit of direction if you're wiling. |
|
@HeWhoWas so if you take a look here: https://github.com/jetstack/cert-manager/blob/master/cmd/ingress-shim/controller/sync_test.go#L76-L126 That's an example of a single test for the You can add your own test cases in there, and also update the existing one that's failing. You will only need to adjust the
Hope that helps - if not, I can put a commit on top of your PR that updates the tests for you, which should hopefully help for next time 😄 |
|
Hey @munnerz - I've been trying to get the time to flesh out the tests, but it appears that going forwards we won't be using the ingress shim and instead use multiple dnsNames for a single certificate. In short, it's unlikely I'll get the time to complete this PR. If you don't mind adding the tests, please do, otherwise I'll just close this off. |
What this PR does / why we need it:
This allows an Ingress to be annotated with 'certmanager.k8s.io/ingress-class: nginx', which signals that any Certificates created for this Ingress resource that use HTTP01 challenges should use ingressClass: instead of ingress:
Which issue this PR fixes fixes #235, fixes #454
Special notes for your reviewer:
I'm not overly familiar with Go, so I expect there might be some things I need to tidy up. I'm not convinced the presence of the annotation should trigger a sync, either. Please let me know if you'd like something changed.
Release note: