K8SPSMDB-1608: add externaldns anotation to create dns for created loadbalancer#2280
Open
myJamong wants to merge 8 commits intopercona:mainfrom
Open
K8SPSMDB-1608: add externaldns anotation to create dns for created loadbalancer#2280myJamong wants to merge 8 commits intopercona:mainfrom
myJamong wants to merge 8 commits intopercona:mainfrom
Conversation
egegunes
requested changes
Mar 10, 2026
pkg/apis/psmdb/v1/psmdb_types.go
Outdated
Comment on lines
+1466
to
+1467
| // +kubebuilder:validation:Required | ||
| Prefix string `json:"prefix"` |
Contributor
There was a problem hiding this comment.
maybe prefix shouldn't be required and operator should use the cluster name by default
Author
There was a problem hiding this comment.
I think its a great idea. I changed it to have default cr name - ee194e4
Comment on lines
+36
to
+38
| if dns.Prefix == "" || dns.Domain == "" { | ||
| return errors.Errorf("externalDNS requires both prefix and domain for replset %s", rs.Name) | ||
| } |
Contributor
There was a problem hiding this comment.
even though this will be handled on CRD level, I think we should do this check in CheckNSetDefaults
Author
There was a problem hiding this comment.
I moved the validation logic - 19a85b2
Thanks for the review!
…unctions to CheckNSetDefaults.
egegunes
previously approved these changes
Mar 10, 2026
Contributor
|
@myJamong please fix manifests by running |
egegunes
approved these changes
Mar 11, 2026
Collaborator
commit: ff70a0b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGE DESCRIPTION
Problem:
When
expose.enabled: truewithtype: LoadBalancer, each per-pod Service gets an auto-assigned LB hostname (e.g.,a1b2c3d4e5.elb.amazonaws.com). These hostnames are not human-readable, long, and unpredictable. The existingexpose.annotationsfield applies the same annotations to every per-pod Service, making it impossible to assign a uniqueexternal-dns.alpha.kubernetes.io/hostnameper pod.This is the issue I made: #2267
Cause:
There was no built-in mechanism to generate unique, per-pod DNS hostname annotations. Users had to manually manage DNS records for each pod's LoadBalancer endpoint.
Solution:
Add an optional
externalDNSfield underexposethat automatically generates uniqueexternal-dns.alpha.kubernetes.io/hostnameannotations for each per-pod Service, enabling ExternalDNS to create human-readable DNS records in any supported DNS provider (Route53, Cloud DNS, Azure DNS, etc.).Configuration
Generated Annotations
Each per-pod Service gets a unique hostname annotation:
my-cluster-rs0-0external-dns.alpha.kubernetes.io/hostname: service-name-rs0-0.mongo.example.commy-cluster-rs0-1external-dns.alpha.kubernetes.io/hostname: service-name-rs0-1.mongo.example.commy-cluster-rs0-2external-dns.alpha.kubernetes.io/hostname: service-name-rs0-2.mongo.example.comIf
ttlis set, theexternal-dns.alpha.kubernetes.io/ttlannotation is also added.Supported Components
{prefix}-{replsetName}-{podIndex}.{domain}{prefix}-mongos-{podIndex}.{domain}{prefix}-mongos.{domain}Note on
serviceAnnotationsoverlapIf
serviceAnnotationscontainsexternal-dns.alpha.kubernetes.io/hostname, theexternalDNSconfig takes precedence and overwrites it. This is by design — whenexternalDNSis configured, it owns the hostname annotation.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability