Skip to content

Commit 68adacf

Browse files
committed
fix: grant more permissions to cloud node lifecycle controller
1 parent 73e4369 commit 68adacf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Diff for: internal/node/utils.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ func StartCloudNodeLifecycleControllerWrapper(initContext app.ControllerInitCont
2929

3030
//nolint:gocritic // need to follow upstream function signature
3131
func startCloudNodeLifecycleController(ctx context.Context,
32-
initContext app.ControllerInitContext,
32+
_ app.ControllerInitContext,
3333
controlexContext controllermanagerapp.ControllerContext,
3434
completedConfig *config.CompletedConfig,
3535
cloud cloudprovider.Interface,
3636
) (controller.Interface, bool, error) {
37+
// Use CCM's kubeconfig to create a clientset for the custom node lifecycle controller because we need permissions
38+
// to list and delete VolumeAttachments
39+
ccmClientSet, err := clientset.NewForConfig(completedConfig.Kubeconfig)
40+
if err != nil {
41+
return nil, false, fmt.Errorf("failed to create clientset from ccm kubeconfig: %w", err)
42+
}
43+
3744
// Start the cloudNodeLifecycleController
3845
cloudNodeLifecycleController, err := NewCloudNodeLifecycleController(
3946
completedConfig.SharedInformers.Core().V1().Nodes(),
40-
// cloud node lifecycle controller uses existing cluster role from node-controller
41-
completedConfig.ClientBuilder.ClientOrDie(initContext.ClientName),
47+
ccmClientSet,
4248
cloud,
4349
completedConfig.ComponentConfig.KubeCloudShared.NodeMonitorPeriod.Duration,
4450
)

0 commit comments

Comments
 (0)