Skip to content

Conversation

@hjoshi123
Copy link
Contributor

What does it do ?

Adds external-dns.alpha.kubernetes.io/gateway-hostname-source annotation to the GatewayAPI source.

Motivation

#5391

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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. source labels May 31, 2025
@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 May 31, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @hjoshi123. 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 May 31, 2025
@ivankatliarchuk
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 1, 2025
@mloiseleur
Copy link
Collaborator

At first glance, it makes sense.
@abursavich Wdyt ? Anything I missed ? Do you think you can review this PR ?

@mloiseleur mloiseleur changed the title feat(source): added gateway api hostname source annotation feat(source): add gateway api hostname source annotation Jun 1, 2025
@bdrewery
Copy link

bdrewery commented Jun 4, 2025

I ran into a case of needing this too.
Probably should update docs/annotations/annotations.md or docs/sources/gateway-api.md or any doc.

@ivankatliarchuk
Copy link
Member

Hi @bdrewery,

Would you be able to share an abstract with a use case for that annotation? This would be incredibly helpful for our documentation; it's always valuable to provide not just the feature itself, but also practical examples of how it can be used.

@ivankatliarchuk
Copy link
Member

I think there is a great explanation about one of the use cases, we could re-use and add it to docs #5391 (comment)

Customers need to be able to resolve most of their traffic over the private endpoint, so they set up DNS for company.private.example.com to point to their internal VPC endpoint. The CNAME then directs traffic from company.public.example.com to company.private.example.com which resolves privately to their internal endpoint. This is then directed to our Gateway API private load balancer, then routed in-cluster.

Some limited traffic from third-party services that our customers use (namely SCIM) cannot traverse this private endpoint, so we need to have that traffic be able to resolve company.private.example.com to our public gateway instead. Inside their network, that will still resolve to their internal endpoint, but those third-party services will be able to send traffic to the public endpoint (which will only handle traffic for a \scim endpoint and blackhole everything else).

The problem is that the hostname those third-party services will have to use is company.public.example.com, so that's the hostname that we need to use on our HTTPRoute. We don't want to override our CNAME however, or that will break our customers other operations. We want external DNS to create ONLY an A record for company.private.example.com -> public gateway loadbalancer DNS, but the default behavior is to add both the hostname annotations and the hostname defined in the HTTPRoute spec, which causes it to override our ExernalName service's CNAME record with a message like this:

@hjoshi123
Copy link
Contributor Author

@ivankatliarchuk yes I was gonna modify the documentation for ingress since the annotation's purpose is similar

@k8s-ci-robot
Copy link
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 assign ivankatliarchuk for approval. 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

@hjoshi123
Copy link
Contributor Author

@bdrewery @ivankatliarchuk added documentation.. let me know if the documentation works

@ivankatliarchuk
Copy link
Member

/ok-to-test

@ivankatliarchuk
Copy link
Member

In docs use-cases missing. And would you be able to share evidences that the code is working and make changes expected?

@hjoshi123
Copy link
Contributor Author

Hmm.. @ivankatliarchuk I will try running it on my homelab over the weekend.. if someone can do it earlier then it would be better too.. the unit tests are passing though
also I think I did add the use-cases in docs/sources under why is this needed?

@mloiseleur
Copy link
Collaborator

/ok-to-test

@ivankatliarchuk
Copy link
Member

Example use cases for another annotation https://github.com/kubernetes-sigs/external-dns/blob/master/docs/advanced/ttl.md#use-cases-for-external-dnsalphakubernetesiottl-annotation. This will help us and a community to decide which annotation to use

@hjoshi123
Copy link
Contributor Author

Ah gotcha @ivankatliarchuk I can add it.. although I didn't get time to run this on a cluster.. but seems like the tests are passing.. I am not sure if any of you guys have bandwidth to try it out

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 9, 2025
@k8s-ci-robot
Copy link
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.

@KalenWessel
Copy link

Checking in to see when this functionality will be merged in? I'm currently running into a similar scenario outlined in this comment

@ivankatliarchuk
Copy link
Member

This PR abandoned. If anyone interested to add feature what is required;

Example result #5828 (comment)

If needed, see how to test a PR. This will require golang to be installed.

@bogdankrasko
Copy link

Smoke tests

Setup

args:
--kubeconfig=/Users/check/.kube/config \
--log-level=info \
--log-format=text \
--interval=1m \
--source=service \
--source=ingress \
--source=gateway-httproute \
--source=gateway-grpcroute \
--source=gateway-tlsroute \
--source=gateway-tcproute \
--source=gateway-udproute \
--policy=upsert-only \
--registry=txt \
--txt-owner-id=check-external.dns \
--provider=aws \
--zone-id-filter=/hostedzone/Z05480953F37UYZ***** \
--domain-filter=dev.poc.engineering

manifest:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: check-external-dns
  namespace: check
  annotations:
    external-dns.alpha.kubernetes.io/gateway-hostname-source: annotation-only
    external-dns.alpha.kubernetes.io/hostname:  >-
      api.us-east-2.check.dev.poc.engineering
spec:
  hostnames:
    - api.check.dev.poc.engineering
    - api.us-east-2.check.dev.poc.engineering
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: public
      namespace: kube-system
  rules:
    - backendRefs:
        - group: ''
          kind: Service
          name: api-use2-1-dev-app
          port: 80

Master

INFO[0000] Instantiating new Kubernetes client          
INFO[0000] Using kubeConfig                             
INFO[0000] Created Kubernetes client https://28C0823905520B****.gr7.us-east-2.eks.amazonaws.com 
INFO[0003] Using kubeConfig                             
INFO[0003] Created GatewayAPI client https://28C0823905520B****.gr7.us-east-2.eks.amazonaws.com 
INFO[0007] Applying provider record filter for domains: [dev.poc.engineering. .dev.poc.engineering.] 
INFO[0007] All records are already up to date           
INFO[0066] Applying provider record filter for domains: [dev.poc.engineering. .dev.poc.engineering.] 
INFO[0067] Desired change: CREATE aaaa-api.us-east-2.check.dev.poc.engineering TXT  profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0067] Desired change: CREATE api.us-east-2.check.dev.poc.engineering A  profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0067] Desired change: CREATE api.us-east-2.check.dev.poc.engineering AAAA  profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0067] Desired change: CREATE api.us-east-2.check.dev.poc.engineering TXT  profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0067] Desired change: CREATE cname-api.us-east-2.check.dev.poc.engineering TXT  profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0067] 5 record(s) were successfully updated         profile=default zoneID=/hostedzone/Z05480953F37UYZ***** zoneName=dev.poc.engineering.
INFO[0127] Applying provider record filter for domains: [dev.poc.engineering. .dev.poc.engineering.] 
INFO[0127] All records are already up to date     

Notes

@ivankatliarchuk Tested feature with latest changes from master branch as well with fixed small merge conflict but I can't push a fix for merge conflict since I don't have persimmons.

# Merge conflict fix
# external-dns/source/annotations/annotations.go
// InternalHostnameKey The annotation used for defining the desired hostname
InternalHostnameKey = AnnotationKeyPrefix + "internal-hostname"
// The annotation used for defining the desired hostname source for gateways
GatewayHostnameSourceKey = AnnotationKeyPrefix + "gateway-hostname-source"

Should I create a new branch or you can fix it?

@mloiseleur
Copy link
Collaborator

Should I create a new branch or you can fix it?

@hjoshi123 Can you update your PR from @bogdankrasko branch ? Or should we create a new PR ?

@bogdankrasko
Copy link

@mloiseleur I've created a new pull request and tested changes #5959

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. docs needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

7 participants