K8SPSMDB-1608: add externaldns annotation to create dns for created loadbalancer#2280
Conversation
| // +kubebuilder:validation:Required | ||
| Prefix string `json:"prefix"` |
There was a problem hiding this comment.
maybe prefix shouldn't be required and operator should use the cluster name by default
There was a problem hiding this comment.
I think its a great idea. I changed it to have default cr name - ee194e4
| if dns.Prefix == "" || dns.Domain == "" { | ||
| return errors.Errorf("externalDNS requires both prefix and domain for replset %s", rs.Name) | ||
| } |
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
There was a problem hiding this comment.
I moved the validation logic - 19a85b2
Thanks for the review!
…unctions to CheckNSetDefaults.
|
@myJamong please fix manifests by running |
Co-authored-by: Mayank Shah <mayankshah1614@gmail.com>
3112f13
|
@myJamong you'll need to run |
|
@myJamong please check the failing unit tests |
Co-authored-by: Mayank Shah <mayankshah1614@gmail.com>
commit: 43b99c0 |
|
@myJamong thanks for your contribution! |
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