@@ -37,6 +37,8 @@ import (
37
37
"github.com/kcp-dev/kcp/pkg/reconciler/workload/heartbeat"
38
38
workloadnamespace "github.com/kcp-dev/kcp/pkg/reconciler/workload/namespace"
39
39
workloadplacement "github.com/kcp-dev/kcp/pkg/reconciler/workload/placement"
40
+ workloadreplicateclusterrole "github.com/kcp-dev/kcp/pkg/reconciler/workload/replicateclusterrole"
41
+ workloadreplicateclusterrolebinding "github.com/kcp-dev/kcp/pkg/reconciler/workload/replicateclusterrolebinding"
40
42
workloadresource "github.com/kcp-dev/kcp/pkg/reconciler/workload/resource"
41
43
synctargetcontroller "github.com/kcp-dev/kcp/pkg/reconciler/workload/synctarget"
42
44
"github.com/kcp-dev/kcp/pkg/reconciler/workload/synctargetexports"
@@ -403,3 +405,57 @@ func (s *Server) installSyncTargetController(ctx context.Context, config *rest.C
403
405
return nil
404
406
})
405
407
}
408
+
409
+ func (s * Server ) installWorkloadReplicateClusterRoleControllers (ctx context.Context , config * rest.Config ) error {
410
+ config = rest .CopyConfig (config )
411
+ config = rest .AddUserAgent (config , workloadreplicateclusterrole .ControllerName )
412
+ kubeClusterClient , err := kcpkubernetesclientset .NewForConfig (config )
413
+ if err != nil {
414
+ return err
415
+ }
416
+
417
+ c := workloadreplicateclusterrole .NewController (
418
+ kubeClusterClient ,
419
+ s .Core .KubeSharedInformerFactory .Rbac ().V1 ().ClusterRoles (),
420
+ s .Core .KubeSharedInformerFactory .Rbac ().V1 ().ClusterRoleBindings (),
421
+ )
422
+
423
+ return s .Core .AddPostStartHook (postStartHookName (workloadreplicateclusterrole .ControllerName ), func (hookContext genericapiserver.PostStartHookContext ) error {
424
+ logger := klog .FromContext (ctx ).WithValues ("postStartHook" , postStartHookName (workloadreplicateclusterrole .ControllerName ))
425
+ if err := s .Core .WaitForSync (hookContext .StopCh ); err != nil {
426
+ logger .Error (err , "failed to finish post-start-hook" )
427
+ return nil // don't klog.Fatal. This only happens when context is cancelled.
428
+ }
429
+
430
+ go c .Start (goContext (hookContext ), 2 )
431
+
432
+ return nil
433
+ })
434
+ }
435
+
436
+ func (s * Server ) installWorkloadReplicateClusterRoleBindingControllers (ctx context.Context , config * rest.Config ) error {
437
+ config = rest .CopyConfig (config )
438
+ config = rest .AddUserAgent (config , workloadreplicateclusterrolebinding .ControllerName )
439
+ kubeClusterClient , err := kcpkubernetesclientset .NewForConfig (config )
440
+ if err != nil {
441
+ return err
442
+ }
443
+
444
+ c := workloadreplicateclusterrolebinding .NewController (
445
+ kubeClusterClient ,
446
+ s .Core .KubeSharedInformerFactory .Rbac ().V1 ().ClusterRoleBindings (),
447
+ s .Core .KubeSharedInformerFactory .Rbac ().V1 ().ClusterRoles (),
448
+ )
449
+
450
+ return s .Core .AddPostStartHook (postStartHookName (workloadreplicateclusterrolebinding .ControllerName ), func (hookContext genericapiserver.PostStartHookContext ) error {
451
+ logger := klog .FromContext (ctx ).WithValues ("postStartHook" , postStartHookName (workloadreplicateclusterrolebinding .ControllerName ))
452
+ if err := s .Core .WaitForSync (hookContext .StopCh ); err != nil {
453
+ logger .Error (err , "failed to finish post-start-hook" )
454
+ return nil // don't klog.Fatal. This only happens when context is cancelled.
455
+ }
456
+
457
+ go c .Start (goContext (hookContext ), 2 )
458
+
459
+ return nil
460
+ })
461
+ }
0 commit comments