Skip to content

feat(gateway): add --resolve-gateway-load-balancer-hostname flag#6286

Closed
Apoorva64 wants to merge 10 commits into
kubernetes-sigs:masterfrom
Orange-OpenSource:feat-add-dns-resolving-to-gateway
Closed

feat(gateway): add --resolve-gateway-load-balancer-hostname flag#6286
Apoorva64 wants to merge 10 commits into
kubernetes-sigs:masterfrom
Orange-OpenSource:feat-add-dns-resolving-to-gateway

Conversation

@Apoorva64

@Apoorva64 Apoorva64 commented Mar 17, 2026

Copy link
Copy Markdown

What does this PR do?

Adds a new --resolve-gateway-load-balancer-hostname boolean flag (default: false) to all Gateway API route sources (HTTPRoute, GRPCRoute, TLSRoute, TCPRoute, UDPRoute).

When enabled, any status.addresses entry on a Gateway with type: Hostname is resolved via DNS (net.LookupIP) and the resulting IP addresses are used as endpoint targets instead of the hostname. This produces A/AAAA records rather than CNAME records.

If DNS resolution fails for a hostname, zero targets are added for that address (same behavior as --resolve-service-load-balancer-hostname).

Motivation

Feature parity with --resolve-service-load-balancer-hostname, which provides the same behavior for Service resources of type LoadBalancer. Some DNS providers or configurations do not support CNAME records (e.g., internal Dns), requiring IP-based records.

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. apis Issues or PRs related to API change labels Mar 17, 2026
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. docs source labels Mar 17, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @Apoorva64!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 17, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @Apoorva64. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 17, 2026
@Apoorva64 Apoorva64 marked this pull request as ready for review March 17, 2026 10:32
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2026
ivankatliarchuk

This comment was marked as duplicate.

ivankatliarchuk

This comment was marked as outdated.

@ivankatliarchuk

Copy link
Copy Markdown
Member

My main concern is that we're slowly accumulating per-source flags. We already have --resolve-service-load-balancer-hostname, and adding --resolve-gateway-load-balancer-hostname starts a pattern that's hard to stop -> next comes --resolve-ingress-, --resolve-istio-, and so on. Once those flags are out in the wild we're stuck with them.

I think we can do better here. Two other options we could/should consider:

  • Generalize --resolve-service-load-balancer-hostname into a single flag that just works for all sources - cleaner for users too.
  • And|Or go the annotation route (external-dns.alpha.kubernetes.io/resolve-target: "true") for per-resource opt-in, which is more flexible and avoids the all-or-nothing problem of global flags.

Either way, the underlying feature make sense to land in external-dns.

@Apoorva64

Copy link
Copy Markdown
Author

I think that option A would be better as when we are using external DNS, the --resolve-service-load-balancer-hostname type flags are used for handling a specific DNS provider.

From what i see this feature is thus tied to a single deployment and should be enabled with a global flag.

@ivankatliarchuk

ivankatliarchuk commented Mar 17, 2026

Copy link
Copy Markdown
Member

I've deleted my initial review comment. It was too big so I simplified, but without options A-B now.

Option A — Generalize the existing --resolve-service-load-balancer-hostname into a single --resolve-load-balancer-hostname flag that applies uniformly across all sources producing hostname-type targets.

Option B — Introduce a per-resource annotation (e.g. external-dns.alpha.kubernetes.io/resolve-target: "true") as a source-agnostic opt-in, and open a design discussion first.

Comment thread docs/sources/gateway.md Outdated

If the `--resolve-gateway-load-balancer-hostname` flag is specified, any address with type
`Hostname` is queried through DNS and any resulting IP addresses are added instead of the hostname.
A DNS query failure results in zero targets being added for that address.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will create endpoint without addresses? It will fail the DNS apply

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I fixed the docs. In the case of DNS failure for an Endpoint, External Dns will log the error and skip the endpoint

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from ivankatliarchuk. For more information see the Code Review Process.

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

Details 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

@Apoorva64 Apoorva64 force-pushed the feat-add-dns-resolving-to-gateway branch from 0b44bf6 to 1c99b54 Compare March 17, 2026 12:59
@Apoorva64 Apoorva64 marked this pull request as draft March 17, 2026 13:04
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2026
@Apoorva64

Copy link
Copy Markdown
Author

@ivankatliarchuk

  • i extracted the resolving to a util
  • i renamed the flag to --resolve-load-balancer-hostname.
  • The flag now also activates the hostname resolving in the service.
  • --resolve-service-load-balancer-hostname is now an alias of --resolve-load-balancer-hostname

We should probably add this for other sources but i think it would be another PR?

@Apoorva64 Apoorva64 marked this pull request as ready for review March 17, 2026 13:33
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2026
@ivankatliarchuk

Copy link
Copy Markdown
Member

Maybe annotation is worth to implement first, as it's provides a better opt-in functionality? Worth to check contribution docs https://github.com/kubernetes-sigs/external-dns/blob/master/docs/contributing/source-wrappers.md for some design ideas.

This may take a while, as pros/cons not yet clear of each approach.

@Apoorva64

Apoorva64 commented Mar 17, 2026

Copy link
Copy Markdown
Author

Maybe annotation is worth to implement first, as it's provides a better opt-in functionality? Worth to check contribution docs https://github.com/kubernetes-sigs/external-dns/blob/master/docs/contributing/source-wrappers.md for some design ideas.

This may take a while, as pros/cons not yet clear of each approach.

i've drafted another approch using the wrappers you mentioned here #6289 it still uses a global var to activate and desactivate the feature.
I am still figuring out how annotations works in the codebase xD

@ivankatliarchuk

Copy link
Copy Markdown
Member

Try to configure locall cluster, this should simplify things

On top of that - wort to ask Chatgpt, Claude and DeepWiki https://deepwiki.com/kubernetes-sigs/external-dns

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

PR needs rebase.

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-sigs/prow repository.

@ivankatliarchuk

Copy link
Copy Markdown
Member

Maybe annotation is worth to implement first, as it's provides a better opt-in functionality? Worth to check contribution docs https://github.com/kubernetes-sigs/external-dns/blob/master/docs/contributing/source-wrappers.md for some design ideas.
This may take a while, as pros/cons not yet clear of each approach.

i've drafted another approch using the wrappers you mentioned here #6289 it still uses a global var to activate and desactivate the feature. I am still figuring out how annotations works in the codebase xD

/close

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

@ivankatliarchuk: Closed this PR.

Details

In response to this:

Maybe annotation is worth to implement first, as it's provides a better opt-in functionality? Worth to check contribution docs https://github.com/kubernetes-sigs/external-dns/blob/master/docs/contributing/source-wrappers.md for some design ideas.
This may take a while, as pros/cons not yet clear of each approach.

i've drafted another approch using the wrappers you mentioned here #6289 it still uses a global var to activate and desactivate the feature. I am still figuring out how annotations works in the codebase xD

/close

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-sigs/prow repository.

@ivankatliarchuk

Copy link
Copy Markdown
Member

#6329

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

Labels

apis Issues or PRs related to API change cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. docs needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants