Skip to content

Add Ingress controller implementation and logic in route controller to reconcile ingresses#4346

Closed
wtam2018 wants to merge 42 commits intoknative:masterfrom
wtam2018:ingress8
Closed

Add Ingress controller implementation and logic in route controller to reconcile ingresses#4346
wtam2018 wants to merge 42 commits intoknative:masterfrom
wtam2018:ingress8

Conversation

@wtam2018
Copy link
Copy Markdown
Contributor

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


@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 13, 2019
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 13, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 13, 2019
Copy link
Copy Markdown
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@wtam2018
Copy link
Copy Markdown
Contributor Author

@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>
@wtam2018 wtam2018 changed the title Ingress8 Add Ingress controller implementation Jun 13, 2019
wtam2018 and others added 7 commits June 13, 2019 01:00
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>
@knative-prow-robot knative-prow-robot added the area/test-and-release It flags unit/e2e/conformance/perf test issues for product features label Jun 18, 2019
@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-unit-tests

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-smoke-tests

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-upgrade-tests

@wtam2018 wtam2018 changed the title Add Ingress controller implementation WIP: Add Ingress controller implementation and logic in route controller to reconcile ingresses Jun 19, 2019
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2019
Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this label needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems kinda redundant, why not use i.Namespace on the calling side directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespaces should match.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they do, right?

return ingress, nil
}

// If that isn't found, then fallback on the legacy selector-based approach.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure there's no legacy methods needed for the all-new ingress? I think all code below this is dead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this set to true anywhere besides tests? If not, shall we ditch it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be moved to a new file ingress.go in the same package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Done.

ingressStatus := ingress.Status
if ingressStatus.LoadBalancer == nil || len(ingressStatus.LoadBalancer.Ingress) == 0 {
func makeServiceSpec(ingressAccessor netv1alpha1.IngressAccessor) (*corev1.ServiceSpec, error) {
//ingressStatus := ingress.Status
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-integration-tests

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-integration-tests

@wtam2018 wtam2018 changed the title WIP: Add Ingress controller implementation and logic in route controller to reconcile ingresses Add Ingress controller implementation and logic in route controller to reconcile ingresses Jun 20, 2019
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 20, 2019
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/networking/v1alpha1/clusteringress_accessors.go Do not exist 100.0%
pkg/apis/networking/v1alpha1/ingress_accessors.go Do not exist 100.0%
pkg/reconciler/ingress/config/istio.go Do not exist 96.9%
pkg/reconciler/ingress/config/store.go Do not exist 100.0%
pkg/reconciler/ingress/controller.go Do not exist 100.0%
pkg/reconciler/ingress/ingress.go Do not exist 77.6%
pkg/reconciler/ingress/resources/gateway.go Do not exist 95.2%
pkg/reconciler/ingress/resources/names/names.go Do not exist 100.0%
pkg/reconciler/ingress/resources/secret.go Do not exist 83.3%
pkg/reconciler/ingress/resources/virtual_service.go Do not exist 100.0%
pkg/reconciler/route/reconcile_resources.go 85.3% 83.6% -1.7
pkg/reconciler/route/resources/ingress.go Do not exist 87.3%
pkg/reconciler/route/resources/service.go 85.7% 85.3% -0.4
pkg/reconciler/route/route.go 84.7% 85.5% 0.9

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-upgrade-tests

2 similar comments
@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-upgrade-tests

@wtam2018
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-upgrade-tests

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@wtam2018: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-knative-serving-upgrade-tests 5dd349e link /test pull-knative-serving-upgrade-tests

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@wtam2018
Copy link
Copy Markdown
Contributor Author

Close this PR and redo with smaller PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/API API objects and controllers area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove cluster scoping of ClusterIngress

9 participants