@@ -37,6 +37,8 @@ import (
3737 ctrl "sigs.k8s.io/controller-runtime"
3838 "sigs.k8s.io/controller-runtime/pkg/client"
3939 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
40+ "sigs.k8s.io/controller-runtime/pkg/handler"
41+ "sigs.k8s.io/controller-runtime/pkg/reconcile"
4042
4143 routev1 "github.com/openshift/api/route/v1"
4244 routeapply "github.com/openshift/client-go/route/applyconfigurations/route/v1"
@@ -220,7 +222,7 @@ func crbNameFromCluster(cluster *rayv1.RayCluster) string {
220222func desiredOAuthClusterRoleBinding (cluster * rayv1.RayCluster ) * rbacapply.ClusterRoleBindingApplyConfiguration {
221223 return rbacapply .ClusterRoleBinding (
222224 crbNameFromCluster (cluster )).
223- WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name }).
225+ WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name , "ray.io/cluster-namespace" : cluster . Namespace }).
224226 WithSubjects (
225227 rbacapply .Subject ().
226228 WithKind ("ServiceAccount" ).
@@ -340,5 +342,18 @@ func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
340342 return ctrl .NewControllerManagedBy (mgr ).
341343 Named (controllerName ).
342344 For (& rayv1.RayCluster {}).
345+ Owns (& corev1.ServiceAccount {}).
346+ Owns (& corev1.Service {}).
347+ Owns (& corev1.Secret {}).
348+ Owns (& routev1.Route {}).
349+ Watches (& rbacv1.ClusterRoleBinding {}, handler .EnqueueRequestsFromMapFunc (
350+ func (c context.Context , o client.Object ) []reconcile.Request {
351+ return []reconcile.Request {{
352+ NamespacedName : client.ObjectKey {
353+ Name : o .GetLabels ()["ray.io/cluster-name" ],
354+ Namespace : o .GetLabels ()["ray.io/cluster-namespace" ],
355+ }}}
356+ }),
357+ ).
343358 Complete (r )
344359}
0 commit comments