-
Notifications
You must be signed in to change notification settings - Fork 446
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
[Feature] Add headServiceLabels field to RayCluster CR #874
[Feature] Add headServiceLabels field to RayCluster CR #874
Conversation
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.
Thank you for your contribution!
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.
Would you mind adding some comments about this field in RayCluster chart, ray-cluster.complete.yaml
, and ray-cluster.complete.large.yaml
?
Is it possible to test whether the labels and selector match or not with unit tests? |
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 have a clear story about labels for the Head service.
Without custom labels for Head service
- Head Pod: labels (
head_pod_labels
) - Head Service:
- selector:
default_labels
(IfKubernetesApplicationNameLabelKey
is defined byhead_pod_labels
, overwrite the default value.) - labels:
default_labels
(IfKubernetesApplicationNameLabelKey
is defined byhead_pod_labels
, overwrite the default value.)
kuberay/ray-operator/controllers/ray/raycluster_controller.go
Lines 309 to 312 in 2600854
labels := make(map[string]string) if val, ok := instance.Spec.HeadGroupSpec.Template.ObjectMeta.Labels[common.KubernetesApplicationNameLabelKey]; ok { labels[common.KubernetesApplicationNameLabelKey] = val }
- selector:
Current status of this PR
- Head Pod: labels (
head_pod_labels
) - Head Service:
- selector:
default_labels
(IfKubernetesApplicationNameLabelKey
is defined byhead_pod_labels
, overwrite the default value.) - labels:
default_labels
(IfKubernetesApplicationNameLabelKey
is defined byhead_pod_labels
, overwrite the default value.) +custom_svc_labels
- selector:
Need to discuss
- Q: Does
HeadService.labels
need to containdefault_labels
?- For me, it seems unnecessary.
- Q: How to handle overlaps between
head_pod_labels
,default_labels
, andcustom_svc_labels
?- In my opinion, for
HeadService.selector
,default_labels
should always respecthead_pod_labels
and ignorecustom_svc_labels
to avoid a mismatch between label and selector. Currently, we only respecthead_pod_labels
when the key isKubernetesApplicationNameLabelKey
.
- In my opinion, for
My current thought
- Head Pod: labels (
head_pod_labels
) - Head Service:
- selector:
default_labels
(if overlaps exist, respecthead_pod_labels
and ignorecustom_svc_labels
.) - labels:
custom_svc_labels
- selector:
cc @DmitriGekhtman @architkulkarni @Jeffwan for more inputs.
I feel we should not update CRD for this kind of change. Let's change to use annotations instead?? This won't be scalable and will constantly introduce more api changes. WDYT? |
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.
Let' have a short discussion on future api changes?
The request in this case was specifically to expose head service labels (we didn't ask what for) |
I followed up with the user on slack. In his words, "just FYI I'm not actively working on this, but the original need was due to use of labels for cross-cluster service discovery".
It seems annotations will not work in this case.
|
@kevin85421 @Yicheng-Lu-llll sorry for late response. I am kind of overwhelmed by internal stuff. For this api change, I feel we can make it with next API version like v1beta1. I will double check your notes and come back to you soon |
@Jeffwan no worries. We may close this PR in favor of exposing the entire service (#877 (comment)) based on community sync on Jan. 31 2023. |
Why are these changes needed?
Users want to set custom labels for the KubeRay Head Service. However, currently, KubeRay only supports custom annotations for the Head Service.
https://ray-distributed.slack.com/archives/C02GFQ82JPM/p1673647485229799
Implementation details and the reasons behind:
changes:
reasons:
There is a reason to call HeadServiceCustomLabels instead of HeadServiceLabels. For kubeRay head service,
labels = five default labels + user-defined custom labels
. HeadServiceCustomLabels filed is only for user-defined custom labels. If we call HeadServiceLabels, users may think they should also add five default labels to this field.kuberay/ray-operator/controllers/ray/common/service.go
Line 49 in d4784a5
In the current implementation, the service selector uses the five default labels. And head pods will have exactly the same default labels. If users overwrite any of the five default labels by setting custom service labels, a mismatch between the head pod and the head service will occur. Note: this is unlike [Bug] Modification of nameOverride will cause label selector mismatch for head node #572, we can not change the head pod's labels.
when saying five default labels above, I am referring to
kuberay/ray-operator/controllers/ray/common/service.go
Line 12 in d4784a5
What next?
In the current implementation, pod labels and service labels are assigned in different places and there is no consistency check. In other words, when modifying the code, we need to manually make sure the value of the default five labels in the service selector and pods are the same.
[TODO] unit tests: whether the labels and selector match or not.
Related issue number
Closes #868
Checks
Step1:
Clone my repo and checkout to
AddCustomLabels
branchStep2:
Follow DEVELOPMENT.md to build Docker image and install kuberay operator.
Step3:
Add the following to the last line of kuberay/ray-operator/config/samples/ray-cluster.complete.yaml
(As @kevin85421 mentions, add app.kubernetes.io/name: "fake_name" to test)
Step4:
Step5:
Step6: Set up port-forwarding
kubectl port-forward svc/raycluster-complete-head-svc 8265:8265
Step7: Submit a simple job
ray job submit --address http://localhost:8265 -- python -c "import ray; ray.init(); print(ray.cluster_resources())"
Step 8: In helm-chart/ray-cluster/values.yaml, add:
Step 9