Multicluster - Support Headless Services that do not match STS serviceName
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 11.5k
- Forks
- 1.4k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 53
Description
### What problem are you trying to solve?
I have a need to export headless services that do not match the statefulset's serviceName (pod's subdomain).
In Kubernetes, the headless service's endpoints do not include a hostname field unless the pod subDomain (pulled from the statefulset's serviceName) matches that of the headless service name.
However, it is viable to create headless services that do not match the serviceName and the targets are still discovered by labels successfully.
The endpoints for a headless service without matching serviceName appear as such:
```
subsets:
- addresses:
- ip: 10.42.0.70
nodeName: k3d-cluster1-agent-1
targetRef:
kind: Pod
name: linkerd-0-1
namespace: mongodb
uid: 57326f33-2938-4041-821c-f631f7ac58db
- ip: 10.42.3.45
nodeName: k3d-cluster1-agent-0
targetRef:
kind: Pod
name: linkerd-0-0
namespace: mongodb
uid: a61525c6-b931-4007-a81d-e7fd053aa132
ports:
- port: 27017
protocol: TCP
```
### How should the problem be solved?
In cluster_watcher_headless.go, function createOrUpdateHeadlessEndpoints has a continue statement when the address.Hostname == "" ([Reference link](https://github.com/linkerd/linkerd2/blob/9c9b4349469049deac88f4407665213ef67eecd1/multicluster/service-mirror/cluster_watcher_headless.go#L103-L105))
Rather than using the hostname for the exported service name, could the cluster watcher mirror it using the targetRef.name instead?
### Any alternatives you've considered?
Create individual services for each statefulset member and label them for export. In the other cluster, create traffic splits to route the original hostname back to the matching exported name.
### How would users interact with this feature?
_No response_
### Would you like to work on this feature?
maybe
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in multicluster/service-mirror/cluster_watcher_headless.go, focusing on createOrUpdateHeadlessEndpoints and the continue for addresses with an empty Hostname. Compare that behavior with the provided Kubernetes endpoint shape and determine how targetRef.name should be handled. Done means headless services without matching serviceName are mirrored successfully while existing hostname-based behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- distributed-systems, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100