Add Ingress controller implementation and logic in route controller to reconcile ingresses#4346
Add Ingress controller implementation and logic in route controller to reconcile ingresses#4346wtam2018 wants to merge 42 commits intoknative:masterfrom
Conversation
|
Hi @wtam2018. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
knative-prow-robot
left a comment
There was a problem hiding this comment.
@wtam2018: 1 warning.
Details
In response to this:
Add ingress controller for Fixes #3982. This is a part of the overall implementation if namespaced ingress. This PR covers the Ingress controller and its resources.
Proposed Changes
- Create Ingress controller based on clusteringress
- Add label keys for Ingress and IngressNamespace
- ClusterIngress label will be "/clusteringress" instead of "/ingress"
Release Note
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.
|
@vagababov I tried to split the PR into purely renaming and logic/other changes. However, I am not sure how feasible it is (to make it compiled and tested) because renamed objects are going to be used differently. I've broken down the PR into small ones. This PR is on the ingress controller side. It is mainly copied from its clusteringress counterpart. I hope it is more reviewable. |
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
Co-Authored-By: mattmoor-sockpuppet <mattmoor+sockpuppet@google.com>
|
/test pull-knative-serving-unit-tests |
|
/test pull-knative-serving-smoke-tests |
|
/test pull-knative-serving-upgrade-tests |
markusthoemmes
left a comment
There was a problem hiding this comment.
Only flyby comments, this is still quite a huge diff to properly review. I'm certainly not a good reviewer for this.
|
|
||
| // IngressNamespaceLabelKey is the label key attached to underlying network programming | ||
| // to indicate which namespace the Ingress was created in. | ||
| IngressNamespaceLabelKey = GroupName + "/ingressNamespace" |
There was a problem hiding this comment.
Why is this label needed?
There was a problem hiding this comment.
These labels are put on virtual services to identify creators/owners. Ingress controller listens to Virtual Service Informer events come from resources with these labels attached.
| // VirtualServices for a given Ingress. | ||
| func IngressVirtualServiceNamespace(i *v1alpha1.Ingress) string { | ||
| return i.Namespace | ||
| } |
There was a problem hiding this comment.
This seems kinda redundant, why not use i.Namespace on the calling side directly?
There was a problem hiding this comment.
This method has been consolidated to conditionally return i.Namespace or system.Namespace.
|
|
||
| virtualServiceInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ | ||
| FilterFunc: myFilterFunc, | ||
| Handler: controller.HandleAll(impl.EnqueueLabelOfNamespaceScopedResource(networking.IngressNamespaceLabelKey, |
There was a problem hiding this comment.
Shouldn't this controller only handle namespaced virtual services in the first place? As such the namespace of the VS should be == that of the ingress and thus the label wouldn't be needed.
There was a problem hiding this comment.
This controller only handles namespaced Ingress (I think that is what you mean). Virtual Services have always been namespaced. Yes, Ingress and its VSes have same namespace. I think we still need these labels to add event handler and handle events to reconcile these children (VSes). These labels are used to find/delete children resources.
|
|
||
| ingressInformer.Informer().AddEventHandler(controller.HandleAll( | ||
| impl.EnqueueLabelOfNamespaceScopedResource( | ||
| serving.RouteNamespaceLabelKey, serving.RouteLabelKey))) |
There was a problem hiding this comment.
The namespaces should match.
There was a problem hiding this comment.
I think they do, right?
| return ingress, nil | ||
| } | ||
|
|
||
| // If that isn't found, then fallback on the legacy selector-based approach. |
There was a problem hiding this comment.
I'm pretty sure there's no legacy methods needed for the all-new ingress? I think all code below this is dead.
There was a problem hiding this comment.
I think you are right. There is unit test that verifies the legacy method (targeted to clusteringress) which also applied to new ingress at the moment. We will clean this (Ingress) up and remove the obsolete unit test when we remove clusteringress.
| clusterIngress, err := c.getClusterIngressForRoute(r) | ||
| if apierrs.IsNotFound(err) { | ||
| // As an optimization, we don't create a cluster ingress if it does not exist already. Ingress will take over | ||
| if !shouldCreateNew { |
There was a problem hiding this comment.
Is this set to true anywhere besides tests? If not, shall we ditch it?
There was a problem hiding this comment.
It is set to true in some unit tests to exercise clusteringress reconciliation.
|
|
||
| // MakeIngress creates ClusterIngress to set up routing rules. Such ClusterIngress specifies | ||
| // which Hosts that it applies to, as well as the routing rules. | ||
| func MakeIngress(ctx context.Context, r *servingv1alpha1.Route, tc *traffic.Config, tls []v1alpha1.IngressTLS, ingressClass string) (*v1alpha1.Ingress, error) { |
There was a problem hiding this comment.
Should this be moved to a new file ingress.go in the same package?
| ingressStatus := ingress.Status | ||
| if ingressStatus.LoadBalancer == nil || len(ingressStatus.LoadBalancer.Ingress) == 0 { | ||
| func makeServiceSpec(ingressAccessor netv1alpha1.IngressAccessor) (*corev1.ServiceSpec, error) { | ||
| //ingressStatus := ingress.Status |
|
/test pull-knative-serving-integration-tests |
|
/test pull-knative-serving-integration-tests |
|
/test pull-knative-serving-upgrade-tests |
2 similar comments
|
/test pull-knative-serving-upgrade-tests |
|
/test pull-knative-serving-upgrade-tests |
|
@wtam2018: The following test failed, say
Full PR test history. Your PR dashboard. 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. |
|
Close this PR and redo with smaller PRs. |
Add ingress controller for Fixes #3982. This is a part of the overall implementation if namespaced ingress. This PR covers the Ingress controller and its resources.
Proposed Changes
Release Note