Skip to content
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

Add Support for Gateway API Route Sources #2292

Merged
merged 7 commits into from May 25, 2022

Conversation

abursavich
Copy link
Contributor

Description

This adds support for Gateway API (v1alpha2 at v0.4.0-rc1) HTTPRoute, TLSRoute, TCPRoute, and UDPRoute kinds as sources.

Since the upstream API is still in alpha, no backwards compatibility guarantees are made for its support in ExternalDNS.

Fixes #2045

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 14, 2021
@abursavich abursavich force-pushed the gateway-redo branch 2 times, most recently from 2245893 to 4b6a8ee Compare September 15, 2021 02:10
@abursavich
Copy link
Contributor Author

Pushed changes to fix some doc formatting and make some names more consistent.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2021
@abursavich
Copy link
Contributor Author

Rebased after dependabot merges.

@abursavich abursavich force-pushed the gateway-redo branch 4 times, most recently from 04d78ec to 603baca Compare September 22, 2021 00:17
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 29, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2021
@abursavich
Copy link
Contributor Author

Updated to sigs.k8s.io/gateway-api@v0.4.0.

@abursavich
Copy link
Contributor Author

Rebased changes from #2371.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 17, 2021
@abursavich
Copy link
Contributor Author

Time to rebase this old PR again

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 18, 2021
@youngnick
Copy link

From a Gateway API point of view, this LGTM. I'd love to see it in, it will really help Gateway API users. (Gateway API maintainer here :) ) The tricky part is in the Gateway and Route checking logic, and that's all correct.

@Raffo, over to you.

@abursavich
Copy link
Contributor Author

/unassign @Raffo
/assign @njuettner

@k8s-ci-robot k8s-ci-robot assigned njuettner and unassigned Raffo Apr 5, 2022
@abursavich
Copy link
Contributor Author

I noticed that @Raffo's status is "💤 Taking a break from open source."

So... reassigned.

@seanmalloy
Copy link
Member

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 22, 2022
@seanmalloy
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 22, 2022
@seanmalloy
Copy link
Member

@njuettner would you have time to take a look at this one?

@seanmalloy
Copy link
Member

/assign @Raffo

Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

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

@abursavich I started to take a look at this PR, added two comments and I appreciate the abundant use of TODOs to signal points in which we might need to offer guidance. My problem reviewing this is that it's really huge and it's hard for me to make a sense of it. I will do the following:

  • ask in Slack is someone is willing to help with the review of this.
  • if we get no answer, give it another pass and eventually merge as it's an optional source anyway and the common parts modified seem fine.

}

func newGatewayRouteSource(clients ClientGenerator, config *Config, kind string, newInformerFn newGatewayRouteInformerFunc) (Source, error) {
ctx := context.TODO()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is context.TODO the right context to use here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so.

https://pkg.go.dev/context#TODO

TODO returns a non-nil, empty Context. Code should use context.TODO when it's unclear which Context to use or it is not yet available (because the surrounding function has not yet been extended to accept a Context parameter).

}

informerFactory := newGatewayInformerFactory(client, config.GatewayNamespace, gwLabels)
gwInformer := informerFactory.Gateway().V1alpha2().Gateways() // TODO: Gateway informer should be shared across gateway sources.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fine with keeping the non shared across resources informers? Could it cause problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't cause problems. The issue is that each informer instance creates another watch on the apiserver. Sharing wherever possible will reduce network traffic and load on the apiserver.

Informers are not shared across existing sources. The node, service, and pod sources are good examples of this duplication.

resourceKey := fmt.Sprintf("%s/%s/%s", kind, meta.Namespace, meta.Name)
providerSpecific, setIdentifier := getProviderSpecificAnnotations(annots)
ttl, err := getTTLFromAnnotations(annots)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we ignore the error here, we'll be passing nil to endpointsForHostname. Would this even be correct? Isn't it better to return the error?

Copy link
Contributor Author

@abursavich abursavich May 4, 2022

Choose a reason for hiding this comment

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

A few sources return the error, but the most common behavior seems to be log a warning and continue. When there's an error, the ttl value is 0 which ends up being replaced with whatever the default ttl is configured as.

e.g.: https://github.com/kubernetes-sigs/external-dns/blob/v0.11.1/source/ingress.go#L229-L234

@abursavich
Copy link
Contributor Author

  • ask in Slack is someone is willing to help with the review of this.

Btw, it's already gotten LGTMs from @youngnick and @seanmalloy.

@seanmalloy
Copy link
Member

@abursavich I started to take a look at this PR, added two comments and I appreciate the abundant use of TODOs to signal points in which we might need to offer guidance. My problem reviewing this is that it's really huge and it's hard for me to make a sense of it. I will do the following:

  • ask in Slack is someone is willing to help with the review of this.
  • if we get no answer, give it another pass and eventually merge as it's an optional source anyway and the common parts modified seem fine.

@Raffo any thoughts on merging this?

@Raffo
Copy link
Contributor

Raffo commented May 25, 2022

We can merge this 👍

@Raffo
Copy link
Contributor

Raffo commented May 25, 2022

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abursavich, Raffo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2022
@k8s-ci-robot k8s-ci-robot merged commit 66e0d8c into kubernetes-sigs:master May 25, 2022
@abursavich abursavich deleted the gateway-redo branch July 13, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

Support for Gateway API
7 participants