@@ -37,6 +37,8 @@ import (
37
37
ctrl "sigs.k8s.io/controller-runtime"
38
38
"sigs.k8s.io/controller-runtime/pkg/client"
39
39
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
40
+ "sigs.k8s.io/controller-runtime/pkg/handler"
41
+ "sigs.k8s.io/controller-runtime/pkg/reconcile"
40
42
41
43
routev1 "github.com/openshift/api/route/v1"
42
44
routeapply "github.com/openshift/client-go/route/applyconfigurations/route/v1"
@@ -220,7 +222,7 @@ func crbNameFromCluster(cluster *rayv1.RayCluster) string {
220
222
func desiredOAuthClusterRoleBinding (cluster * rayv1.RayCluster ) * rbacapply.ClusterRoleBindingApplyConfiguration {
221
223
return rbacapply .ClusterRoleBinding (
222
224
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 }).
224
226
WithSubjects (
225
227
rbacapply .Subject ().
226
228
WithKind ("ServiceAccount" ).
@@ -340,5 +342,18 @@ func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
340
342
return ctrl .NewControllerManagedBy (mgr ).
341
343
Named (controllerName ).
342
344
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
+ ).
343
358
Complete (r )
344
359
}
0 commit comments