-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ingress V1: support IngressClass #2146
Comments
We need to add a flag I think to buy into this appropriately before making this standard. I'm proposing an Today Contour matches on the following rules:
The new Ingress v1 adds a The docs say that the annotation should take precedence over the spec.ingressclassname. If spec.ingressclassname does not match an IngressClass object then no match, however, we can have an What we need is a way to know when we're going to enforce the ingressv1 behavior by requiring ingressclasses. |
The other way to think about this is if not using annotations, we could just require a default ingressclass to be created. I think that makes sense, but I want to chat about it further first. |
Here are the rules I've come up with which I think covers all the cases we could run into: If
If
If both annotation & Note: This does re-use the |
From the docs it looks like the new |
We need to only filter on the |
So I guess in that scenario, the user would need to specify I was thinking about the scenario where they haven't specified |
Yup if you want to use multiple instances of Contour in the same cluster, you'd have to set If you do not supply |
I read those rules 3 times and I'm not sure that I have got them right. That suggests to me that it's too complicated and we should simplify. What if we add a flag to enable ingress class resource. This acts an an opt-in, and is probably required anyway since you need to specify a namespace and name for the object. The config associated with the ingress class resource can also specify the corresponding ingress class name, so we can statically know (and validate) the correspondence. |
I thought you only specified a name for an IngressClass object, implying that they're effectively global? If that's the case, then @stevesloka's proposal is the best we can get, because it's part of the implementation contract. Adding a flag is not as simple as it sounds, because enabling the flag requires drawing a line under what version of Kubernetes you're running on. I'm not sure what version the new object was actually added in. That said, there's also no good way to programmatically enable it without doing #2219. |
@youngnick I found another interesting case. If I insert a bunch of objects that reference an IngressClass that does not yet exist, then the objects are thrown out of our cache, however, if later the IngressClass is created, they should then all be valid, but they aren't in the cache. I was going to move the logic to validate the ingress objects to the dag.Builder, but wanted to check in first. Thoughts? |
If we move the logic to valid the ingress objects to the Builder, that will mean that the cache will always hold all ingress objects. That doesn't seem ideal, but the only other way I can think of to deal with this is to have a new relevant ingress class kick off a cache refresh for all the ingress objects, which also doesn't seem ideal. This is also relevant because we will most likely have a similar problem with GatewayClass. @jpeach, @skriss, thoughts on keeping ingress-class relevant objects in the cache, and bring them in and out of scope with filtering? The original conception of the Contour cache is that it only holds objects needed for the DAG build, so it is a bit of a change. |
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
…gress objects Add support for IngressClass objects which match the controller name of 'projectcontour.io/ingress-controller'. Any Ingress object which defines an 'Spec.IngressClassName', Contour will validate that a corresponding IngressClass exists. Current ingress class logic for Contour is not affected and still take priority over any IngressClass logic. Signed-off-by: Steve Sloka <[email protected]>
I think that @stevesloka's rules in that comment make sense, but implementing them means that Contour will need to keep all Ingress objects and all IngressClass objects in its cache, and filter them on DAG run. I think it's okay, it's a memory cost per Contour, but worth spending memory on, as the other options are many times more complicated. I'm not sure if the default IngressClass behavior is implemented in a core Kube controller, or if we're supposed to do it. I suspect the latter, tbh. The reason I was blocking this on the decision ticket (#2809 ) was that we needed to figure out if we would support multiple *Class objects in a single Contour, or not. We've decided not to do that, so the rules above are perfect. @stevesloka, sorry to have delayed this. |
It's implemented by Kube - try creating an IngressClass annotated as default, and then an ingress with no class: IngressClass: apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: foo
annotations:
"ingressclass.kubernetes.io/is-default-class": "true"
spec:
controller: projectcontour.io/contour Ingress: apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: basic
spec:
rules:
- host: localhost
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: s1
port:
number: 80 Now get the Ingress YAML (irrelevant bits removed): apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: basic
namespace: default
spec:
ingressClassName: foo
rules:
- host: localhost
http:
paths:
- backend:
service:
name: s1
port:
number: 80
path: /
pathType: Prefix
status:
loadBalancer:
ingress:
- ip: xx.xxx.xx.xxx Note |
Awesome, thanks @skriss ! |
is this in the v1.13 or has it been pushed out to v1.14? |
Cross referencing an Ingress class (albeit Ingress v1beta1 annotation) request: projectcontour/contour-operator#228 |
@stevesloka BTW are you still actively working on this? |
No @sunjayBhatia I'll unassign. I had an impl, then it was closed, created the design doc, then here we are. Feel free to work on it or anyone else can pick up. =) |
Another edge case related to default IngressClass:
|
Is there any reason we would want to configure routes for an Ingress with an ingress class annotation that is not what contour is looking for but an ingress class name in the spec that is? e.g.
|
The KEP had some info about priority here - from https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/1453-ingress-api#interoperability-with-previous-annotation:
|
Oh perfect thanks for that! |
There is a |
Re: I'm not sure I agree with this rule:
|
Similar to the above, Re It seems to me that we can ignore this rule? Seems like we should just ensure we only configure routes for Ingresses that match the configured class name and not have to worry about what is default, the admission controller etc. should ensure new Ingress objects have a class set if they are created without one and there is a default, and should ensure a specific class is set if there are multiple defaults |
Yep I agree with that, Contour shouldn't have to worry about what's the default ingress class, it just looks at what's on the Ingress vs. what's been configured for Contour to watch. |
What happens when you create an Ingress with a valid IngressClassName that Contour is watching but the actual IngressClass does not exist? |
We should be moving to v1.Ingress everywhere as much as possible, as v1beta1.Ingress will be removed from newer versions of Kubernetes soon, and v1.Ingress has been present since 1.16. |
The KEP says
To put that another way, the IngressClass object itself is used for:
So, it turns out we should have read access to them in case we add that later, and to check for default setup weirdness, but aside from that, we should just be able to key off the field in the spec. |
Somewhat a sad I have to go back to the KEP to read the spec and it's not on a site like we have with Gateway API :( |
Ingress V1 changes the IngressClass string to a document.
https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/20190125-ingress-api-group.md#ingress-class
cmluciano/kubernetes#3
The text was updated successfully, but these errors were encountered: