Skip to content

feat: allow overriding external-dns hostname annotation#3087

Open
raphaeltorquat0 wants to merge 1 commit intozalando:masterfrom
raphaeltorquat0:fix/issue-2591-external-dns-override
Open

feat: allow overriding external-dns hostname annotation#3087
raphaeltorquat0 wants to merge 1 commit intozalando:masterfrom
raphaeltorquat0:fix/issue-2591-external-dns-override

Conversation

@raphaeltorquat0
Copy link
Copy Markdown

Summary

Allows users to override the external-dns.alpha.kubernetes.io/hostname annotation by specifying it in serviceAnnotations, masterServiceAnnotations, or replicaServiceAnnotations in the cluster manifest.

Fixes #2591

Changes

  • pkg/cluster/k8sres.go: Modified generateServiceAnnotations() to check if the DNS annotation already exists before setting it
  • pkg/cluster/cluster_test.go: Updated tests to verify user-defined annotations are preserved (changed test case names and expectations)
  • docs/administrator.md: Updated documentation to reflect that the annotation can now be overwritten

Before

The operator always overwrote the external-dns.alpha.kubernetes.io/hostname annotation with the value from master_dns_name_format or replica_dns_name_format, ignoring any user-defined value.

After

If the user has already defined the external-dns.alpha.kubernetes.io/hostname annotation in their service annotations, the operator will preserve that value instead of overwriting it.

Test plan

  • Updated existing tests to verify new behavior
  • All unit tests pass (go test ./...)

Disclosure: I used AI assistance (Claude) to help implement this change under my review and testing.

This change allows users to override the external-dns.alpha.kubernetes.io/hostname
annotation by specifying it in serviceAnnotations, masterServiceAnnotations,
or replicaServiceAnnotations in the cluster manifest.

Previously, the operator always overwrote this annotation with the value from
master_dns_name_format or replica_dns_name_format. Now, if the user has
already defined the annotation, the operator will preserve the user's value.

Changes:
- Modified generateServiceAnnotations() to check if annotation exists before setting
- Updated tests to verify user-defined annotations are preserved
- Updated documentation to reflect the new behavior

Closes zalando#2591
@raphaeltorquat0
Copy link
Copy Markdown
Author

Hi @FxKu, could you please add the minor label so the CI checks can proceed? Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Why is it impossible to override external-dns.alpha.kubernetes.io/hostname on cluster-level?

1 participant