-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headless Service Per Replica KEP #188
Headless Service Per Replica KEP #188
Conversation
|
||
### Implementation | ||
|
||
With HeadlessServicePerReplica true, we will create a headless service per replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we create a headless service per statefulset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the leader will have one, while the workers will have a different one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, ideally we only need the headless service to generate the dns record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the benefits of creating a new one per statefulset instead? Creating a new one per sts creates more headless services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headless service name will be part of the fully qualified host name of the pod, so how many and what name we give the service matters. It is also why I am suggesting that the API to be a knob that decides on the subdomain policy because this is the user facing side effect.
The pod hostname is <pod-name>.<svc-name>
So if the new "policy" is UniquePerReplica
, then each replica including the leader should be part of the same headless service so that the middle part above is common among the pods of a replica. Example:
Replica 0:
- my-lws-0.my-lws-0
- my-lws-0-1.my-lws-0
Replica 1:
- my-lws-1.my-lws-1
- my-lws-1-1.my-lws-1
If we create a headless service per sts including a special one for leaders, then we can't achieve the above since the leader will have a different subdomain name. Here is what it will look like:
Replica 0:
- my-lws-0.my-lws
- my-lws-0-1.my-lws-0
Replica 1:
- my-lws-1.my-lws
- my-lws-1-1.my-lws-1
I am fine with the above, but what would we call such a domain name "policy"? it wouldn't be UniquePerReplica
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UniquePerReplicaWorkers
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me, but it does rely on the assumption that if the subdomain is UniquePerReplicaWorkers
, that means that the leaders must have their own subdomain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about leaderSharedWorkerDedicated
vs shared
or leaderWorkerShared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of the three I prefer leaderSharedWorkerDedicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LeadersSharedWorkersDedicated
```golang | ||
for i := 0; i < lws.Spec.Replicas; i++ { | ||
headlessService := corev1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: fmt.Sprintf("%s-%s", lws.Name, i), | ||
Namespace: lws.Namespace, | ||
}, | ||
Spec: corev1.ServiceSpec{ | ||
ClusterIP: "None", // defines service as headless | ||
Selector: map[string]string{ | ||
leaderworkerset.GroupIndexLabelKey: i, | ||
}, | ||
PublishNotReadyAddresses: true, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to select the generated pods to these headless service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses the GroupIndexLabelKey as selector, so that way all pods that are part of the same replica are selected to the same headless service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add the details how pods will be selected by which headless service as well
|
||
### Implementation | ||
|
||
With HeadlessServicePerReplica true, we will create a headless service per replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headless service name will be part of the fully qualified host name of the pod, so how many and what name we give the service matters. It is also why I am suggesting that the API to be a knob that decides on the subdomain policy because this is the user facing side effect.
The pod hostname is <pod-name>.<svc-name>
So if the new "policy" is UniquePerReplica
, then each replica including the leader should be part of the same headless service so that the middle part above is common among the pods of a replica. Example:
Replica 0:
- my-lws-0.my-lws-0
- my-lws-0-1.my-lws-0
Replica 1:
- my-lws-1.my-lws-1
- my-lws-1-1.my-lws-1
If we create a headless service per sts including a special one for leaders, then we can't achieve the above since the leader will have a different subdomain name. Here is what it will look like:
Replica 0:
- my-lws-0.my-lws
- my-lws-0-1.my-lws-0
Replica 1:
- my-lws-1.my-lws
- my-lws-1-1.my-lws-1
I am fine with the above, but what would we call such a domain name "policy"? it wouldn't be UniquePerReplica
.
…ca number of services for the workers
Changed implementation to creating a headless service per sts. Still have to come up with a name for the new subdomainPolicy. |
service for all of the leaders, and a headless service per replica for the workers. In order | ||
to ensure backwards compatability, the default value if non is set will be Shared. | ||
|
||
A label will be added to determine whether a pod is a leader or a worker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have too many labels, can't we determine by the workerIndex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use workerIndex = 0
to select the leaders, but cannot do workerIndex != 0
to select the workers since AFAIK selector does not have that capability.
// SubdomainUniquePerReplica will create a headless service for each | ||
// leader-worker group. | ||
// The leader host names will look like: | ||
// Replica 0: my-lws-0.my-lws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, if uniquePerReplica
, which means the leader pod and the worker Pods should have the same svc name, but here they're different. my-lws-0.my-lws
vs my-lws-0-1.my-lws-0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is for headless service per sts, still figuring out a naming scheme so left the old name to discuss it further
|
||
### Implementation | ||
|
||
With HeadlessServicePerReplica true, we will create a headless service per replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the uniquePerReplica option. It makes sense for the leader and worker to have the subdomain in common.
+1, or it's weird I think, unless we have other use cases like visiting the workers only.
|
||
### Implementation | ||
|
||
With HeadlessServicePerReplica true, we will create a headless service per replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LeadersSharedWorkersDedicated
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, Edwinhr716 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it
KEP for #173 .
Based on original KEP #177. Added suggestions, and modified the way LWS_LEADER_ADDRESS is set.
Which issue(s) this PR fixes
Fixes #
Special notes for your reviewer
Does this PR introduce a user-facing change?