Skip to content

Conversation

@vaspoz
Copy link

@vaspoz vaspoz commented Nov 29, 2025

What does it do ?

This PR adds support for Azure DNS metadata (tags) in external-dns. Users can now annotate Kubernetes resources with external-dns.alpha.kubernetes.io/azure-metadata-* annotations to set Azure resource tags on the corresponding DNS records.

Motivation

Azure DNS records support metadata (tags) for resource organization, cost tracking, and compliance. This feature enables Kubernetes users to manage DNS record tags declaratively through annotations, making it easier to:

  • Track which Kubernetes resources created which DNS records
  • Organize DNS records by environment, team, or cost center
  • Implement governance and compliance policies at the DNS level

More

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

@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 raffo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 docs provider Issues or PRs related to a provider source labels Nov 29, 2025
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Welcome @vaspoz!

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 Nov 29, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @vaspoz. Thanks for your PR.

I'm waiting for a github.com 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.

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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 29, 2025
@vaspoz vaspoz changed the title feat: Add Azure DNS metadata (tags) support feat(azure): Add Azure DNS metadata (tags) support Nov 29, 2025
@vaspoz vaspoz force-pushed the azure-metadata-support branch from d8b61e6 to f5a5147 Compare November 29, 2025 09:37
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 29, 2025
@vflaux
Copy link
Contributor

vflaux commented Nov 29, 2025

/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 Nov 29, 2025
@coveralls
Copy link

coveralls commented Nov 29, 2025

Pull Request Test Coverage Report for Build 19870223885

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 72 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.02%) to 78.687%

Files with Coverage Reduction New Missed Lines %
apis/externaldns/types.go 1 99.71%
plan.go 3 95.85%
coredns/coredns.go 31 90.36%
azure/azure.go 37 80.37%
Totals Coverage Status
Change from base Build 19788190926: 0.02%
Covered Lines: 16038
Relevant Lines: 20382

💛 - Coveralls

@vaspoz vaspoz force-pushed the azure-metadata-support branch 2 times, most recently from 2199546 to 3b0223c Compare November 30, 2025 08:24
@vaspoz vaspoz force-pushed the azure-metadata-support branch from 3b0223c to 83edb29 Compare November 30, 2025 08:34
@ivankatliarchuk
Copy link
Member

Hi. Could you share similar results for this PR #5085 (comment). Need to make sure it works before we merge. What we looking as well, where or not the behaviour works when tags added, deleted, modified.

Copy link
Contributor

@vflaux vflaux left a comment

Choose a reason for hiding this comment

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

Hi,
You could add test cases in TestAzureApplyChanges() like this one:

	endpoint.NewEndpointWithTTL("metadata.example.com", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").
			WithProviderSpecific("azure-metadata-foo", "bar").
			WithProviderSpecific("azure-metadata-baz", "qux"),

This should cover your code without adding new tests.

@vaspoz
Copy link
Author

vaspoz commented Dec 2, 2025

@ivankatliarchuk , here's the tests outputs:
Test A: Add new metadata

  1. Create HTTPRoute:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: test-metadata-add
  annotations:
    external-dns.alpha.kubernetes.io/azure-metadata-environment: production
    external-dns.alpha.kubernetes.io/azure-metadata-team: platform
    external-dns.alpha.kubernetes.io/azure-metadata-cost-center: "12345"
spec:
  hostnames:
    - metadata-test.basil.sbx.org.cloud
  parentRefs:
    - name: internal
      namespace: istio-system
      sectionName: https
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: dummy-service
          port: 80
  1. Check the resources:
❯ az network dns record-set a show \
  --resource-group $RESOURCE_GROUP \
  --zone-name $DNS_ZONE \
  --name metadata-test \
  --query "metadata" \
  -o json
---
{
  "cost-center": "12345",
  "environment": "production",
  "team": "platform"
}

Test B: Update metadata

  1. Apply updated manifest:
# Test Case 2: Modify Metadata Tags on an Existing DNS Record
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: test-metadata-add
  annotations:
    external-dns.alpha.kubernetes.io/azure-metadata-environment: staging
    external-dns.alpha.kubernetes.io/azure-metadata-team: backend
    external-dns.alpha.kubernetes.io/azure-metadata-owner: john-doe
    # cost-center annotation removed
spec:
  hostnames:
    - metadata-test.basil.sbx.org.cloud
  parentRefs:
    - name: internal
      namespace: istio-system
      sectionName: https
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: dummy-service
          port: 80
  1. Check the metadata:
❯ az network dns record-set a show \
  --resource-group $RESOURCE_GROUP \
  --zone-name $DNS_ZONE \
  --name metadata-test \
  --query "metadata" \
  -o json
---
{
  "environment": "staging",
  "owner": "john-doe",
  "team": "backend"
}

Test C: Delete metadata

  1. Apply udpated manifest:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: test-metadata-add
  annotations:
    # All azure-metadata-* annotations removed
spec:
  hostnames:
    - metadata-test.basil.sbx.org.cloud
  parentRefs:
    - name: internal
      namespace: istio-system
      sectionName: https
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: dummy-service
          port: 80
  1. Check the metadata:
❯ az network dns record-set a show \
  --resource-group $RESOURCE_GROUP \
  --zone-name $DNS_ZONE \
  --name metadata-test \
  --query "metadata" \
  -o json
---
<no output>

Test D: Special characters

  1. Apply new manifest:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: test-metadata-special
  annotations:
    external-dns.alpha.kubernetes.io/azure-metadata-description: "Test service for app-v2.0"
    external-dns.alpha.kubernetes.io/azure-metadata-contact-email: "[email protected]"
spec:
  hostnames:
    - metadata-special.basil.sbx.org.cloud
  parentRefs:
    - name: internal
      namespace: istio-system
      sectionName: https
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: dummy-service
          port: 80
  1. Check the metadata:
❯ az network dns record-set a show \
  --resource-group $RESOURCE_GROUP \
  --zone-name $DNS_ZONE \
  --name metadata-special \
  --query "metadata" \
  -o json
---
{
  "contact-email": "[email protected]",
  "description": "Test service for app-v2.0"
}

Logs:

time="2025-12-02T17:15:53Z" level=info msg="Updating A record named 'metadata-test' to '9.163.156.200' for Azure DNS zone 'basil.sbx.org.cloud'."
time="2025-12-02T17:15:53Z" level=info msg="Updating TXT record named 'a-metadata-test' to '\"heritage=external-dns,external-dns/owner=default,external-dns/resource=httproute/test-metadata/test-metadata-add\"' for Azure DNS zone 'basil.sbx.org.cloud'."
time="2025-12-02T17:16:54Z" level=info msg="Updating A record named 'metadata-test' to '9.163.156.200' for Azure DNS zone 'basil.sbx.org.cloud'."
time="2025-12-02T17:16:55Z" level=info msg="Updating TXT record named 'a-metadata-test' to '\"heritage=external-dns,external-dns/owner=default,external-dns/resource=httproute/test-metadata/test-metadata-add\"' for Azure DNS zone 'basil.sbx.org.cloud'."
time="2025-12-02T17:17:54Z" level=info msg="Updating A record named 'metadata-special' to '9.163.156.200' for Azure DNS zone 'basil.sbx.org.cloud'."
time="2025-12-02T17:17:54Z" level=info msg="Updating TXT record named 'a-metadata-special' to '\"heritage=external-dns,external-dns/owner=default,external-dns/resource=httproute/test-metadata/test-metadata-special\"' for Azure DNS zone 'basil.sbx.org.cloud'."

@vaspoz vaspoz requested a review from vflaux December 5, 2025 13:54
@mloiseleur mloiseleur changed the title feat(azure): Add Azure DNS metadata (tags) support feat(azure): azure dns metadata (tags) support Dec 7, 2025
parentRefs:
- name: my-gateway
hostnames:
- "api.example.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: This is under discussion in gateway-api if this is what we should support or not.

metadata:
name: my-ingress
annotations:
external-dns.alpha.kubernetes.io/azure-metadata-cost-center: "12345"
Copy link
Member

Choose a reason for hiding this comment

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

It does not looks consistent with other providers like aws or cloudflare

Could we have

external-dns.alpha.kubernetes.io/azure-tags: "cost-center=12345,owner=backend-team"

Current approach will require way to many annotaions on objects, and I did not get from first look that two annotations actually represent tags. There are of course limitations on number of annotitionas and character limit on annotations values. I think we better be consistent for now.

Kubernetes has 63 characters limitation on the annotation name. Example external-dns.alpha.kubernetes.io/azure-metadata-cost-center is already 59....

@mloiseleur mloiseleur changed the title feat(azure): azure dns metadata (tags) support feat(azure): dns metadata (tags) support Dec 14, 2025
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 ok-to-test Indicates a non-member PR verified by an org member that is safe to test. provider Issues or PRs related to a provider 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.

6 participants