@@ -86,8 +86,9 @@ const (
8686)
8787
8888var (
89- deletePolicy = metav1 .DeletePropagationForeground
90- deleteOptions = client.DeleteOptions {PropagationPolicy : & deletePolicy }
89+ deletePolicy = metav1 .DeletePropagationForeground
90+ deleteOptions = client.DeleteOptions {PropagationPolicy : & deletePolicy }
91+ defaultHashLength = 8
9192)
9293
9394// +kubebuilder:rbac:groups=ray.io,resources=rayclusters,verbs=get;list;watch;create;update;patch;delete
@@ -304,7 +305,7 @@ func isMTLSEnabled(cfg *config.KubeRayConfiguration) bool {
304305}
305306
306307func crbNameFromCluster (cluster * rayv1.RayCluster ) string {
307- return cluster .Name + "-" + cluster .Namespace + "-auth" // NOTE: potential naming conflicts ie {name: foo, ns: bar-baz} and {name: foo-bar, ns: baz}
308+ return cluster .Name + "-" + cluster .Namespace + "-auth-" + ControllerSpecificHash ( cluster . Name , defaultHashLength ) // NOTE: potential naming conflicts ie {name: foo, ns: bar-baz} and {name: foo-bar, ns: baz}
308309}
309310
310311func desiredOAuthClusterRoleBinding (cluster * rayv1.RayCluster ) * rbacv1ac.ClusterRoleBindingApplyConfiguration {
@@ -326,7 +327,7 @@ func desiredOAuthClusterRoleBinding(cluster *rayv1.RayCluster) *rbacv1ac.Cluster
326327}
327328
328329func oauthServiceAccountNameFromCluster (cluster * rayv1.RayCluster ) string {
329- return cluster .Name + "-oauth-proxy"
330+ return cluster .Name + "-oauth-proxy-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
330331}
331332
332333func desiredServiceAccount (cluster * rayv1.RayCluster ) * corev1ac.ServiceAccountApplyConfiguration {
@@ -343,11 +344,11 @@ func desiredServiceAccount(cluster *rayv1.RayCluster) *corev1ac.ServiceAccountAp
343344}
344345
345346func dashboardNameFromCluster (cluster * rayv1.RayCluster ) string {
346- return "ray-dashboard-" + cluster .Name
347+ return "ray-dashboard-" + cluster .Name + "-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
347348}
348349
349350func rayClientNameFromCluster (cluster * rayv1.RayCluster ) string {
350- return "rayclient-" + cluster .Name
351+ return "rayclient-" + cluster .Name + "-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
351352}
352353
353354func desiredClusterRoute (cluster * rayv1.RayCluster ) * routev1ac.RouteApplyConfiguration {
@@ -367,11 +368,11 @@ func desiredClusterRoute(cluster *rayv1.RayCluster) *routev1ac.RouteApplyConfigu
367368}
368369
369370func oauthServiceNameFromCluster (cluster * rayv1.RayCluster ) string {
370- return cluster .Name + "-oauth"
371+ return cluster .Name + "-oauth-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
371372}
372373
373374func oauthServiceTLSSecretName (cluster * rayv1.RayCluster ) string {
374- return cluster .Name + "-proxy-tls-secret"
375+ return cluster .Name + "-proxy-tls-secret-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
375376}
376377
377378func desiredOAuthService (cluster * rayv1.RayCluster ) * corev1ac.ServiceApplyConfiguration {
@@ -395,7 +396,7 @@ func desiredOAuthService(cluster *rayv1.RayCluster) *corev1ac.ServiceApplyConfig
395396}
396397
397398func oauthSecretNameFromCluster (cluster * rayv1.RayCluster ) string {
398- return cluster .Name + "-oauth-config"
399+ return cluster .Name + "-oauth-config-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
399400}
400401
401402// desiredOAuthSecret defines the desired OAuth secret object
@@ -414,7 +415,7 @@ func desiredOAuthSecret(cluster *rayv1.RayCluster, cookieSalt string) *corev1ac.
414415}
415416
416417func caSecretNameFromCluster (cluster * rayv1.RayCluster ) string {
417- return "ca-secret-" + cluster .Name
418+ return "ca-secret-" + cluster .Name + "-" + ControllerSpecificHash ( cluster . Name , defaultHashLength )
418419}
419420
420421func desiredCASecret (cluster * rayv1.RayCluster , key , cert []byte ) * corev1ac.SecretApplyConfiguration {
@@ -476,7 +477,9 @@ func generateCACertificate() ([]byte, []byte, error) {
476477}
477478
478479func desiredWorkersNetworkPolicy (cluster * rayv1.RayCluster ) * networkingv1ac.NetworkPolicyApplyConfiguration {
479- return networkingv1ac .NetworkPolicy (cluster .Name + "-workers" , cluster .Namespace ).
480+ return networkingv1ac .NetworkPolicy (
481+ cluster .Name + "-workers-" + ControllerSpecificHash (cluster .Name , defaultHashLength ), cluster .Namespace ,
482+ ).
480483 WithLabels (map [string ]string {RayClusterNameLabel : cluster .Name }).
481484 WithSpec (networkingv1ac .NetworkPolicySpec ().
482485 WithPodSelector (metav1ac .LabelSelector ().WithMatchLabels (map [string ]string {"ray.io/cluster" : cluster .Name , "ray.io/node-type" : "worker" })).
@@ -499,7 +502,7 @@ func desiredHeadNetworkPolicy(cluster *rayv1.RayCluster, cfg *config.KubeRayConf
499502 if ptr .Deref (cfg .MTLSEnabled , true ) {
500503 allSecuredPorts = append (allSecuredPorts , networkingv1ac .NetworkPolicyPort ().WithProtocol (corev1 .ProtocolTCP ).WithPort (intstr .FromInt (10001 )))
501504 }
502- return networkingv1ac .NetworkPolicy (cluster .Name + "-head" , cluster .Namespace ).
505+ return networkingv1ac .NetworkPolicy (cluster .Name + "-head-" + ControllerSpecificHash ( cluster . Name , defaultHashLength ) , cluster .Namespace ).
503506 WithLabels (map [string ]string {RayClusterNameLabel : cluster .Name }).
504507 WithSpec (networkingv1ac .NetworkPolicySpec ().
505508 WithPodSelector (metav1ac .LabelSelector ().WithMatchLabels (map [string ]string {"ray.io/cluster" : cluster .Name , "ray.io/node-type" : "head" })).
0 commit comments