From 05c53a206ec51d4c5878c8056c813d8e4c45b2fc Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Thu, 13 Jun 2024 20:05:39 +0300 Subject: [PATCH] forklift: add missing rbac Signed-off-by: Benny Zlotnik --- pkg/operator/resources/cluster/controller.go | 4 +- pkg/operator/resources/cluster/rbac.go | 45 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/pkg/operator/resources/cluster/controller.go b/pkg/operator/resources/cluster/controller.go index 2760dd2015..15a1693fd1 100644 --- a/pkg/operator/resources/cluster/controller.go +++ b/pkg/operator/resources/cluster/controller.go @@ -275,9 +275,7 @@ func getControllerClusterPolicyRules() []rbacv1.PolicyRule { "openstackvolumepopulators", }, Verbs: []string{ - "get", - "list", - "watch", + "*", }, }, } diff --git a/pkg/operator/resources/cluster/rbac.go b/pkg/operator/resources/cluster/rbac.go index 59a9899eab..f4d1408a68 100644 --- a/pkg/operator/resources/cluster/rbac.go +++ b/pkg/operator/resources/cluster/rbac.go @@ -30,8 +30,13 @@ func createAggregateClusterRoles(_ *FactoryArgs) []client.Object { utils.ResourceBuilder.CreateAggregateClusterRole("cdi.kubevirt.io:admin", "admin", getAdminPolicyRules()), utils.ResourceBuilder.CreateAggregateClusterRole("cdi.kubevirt.io:edit", "edit", getEditPolicyRules()), utils.ResourceBuilder.CreateAggregateClusterRole("cdi.kubevirt.io:view", "view", getViewPolicyRules()), + utils.ResourceBuilder.CreateAggregateClusterRole("forklift.cdi.kubevirt.io:admin", "admin", getAdminPolicyRules()), + utils.ResourceBuilder.CreateAggregateClusterRole("forklift.cdi.kubevirt.io:edit", "edit", getEditPolicyRules()), + utils.ResourceBuilder.CreateAggregateClusterRole("forklift.cdi.kubevirt.io:view", "view", getViewPolicyRules()), createConfigReaderClusterRole("cdi.kubevirt.io:config-reader"), + createConfigReaderClusterRole("forklift.cdi.kubevirt.io:config-reader"), createConfigReaderClusterRoleBinding("cdi.kubevirt.io:config-reader"), + createConfigReaderClusterRoleBinding("forklift.cdi.kubevirt.io:config-reader"), } } @@ -75,6 +80,18 @@ func getAdminPolicyRules() []rbacv1.PolicyRule { "*", }, }, + { + APIGroups: []string{ + "forklift.cdi.kubevirt.io", + }, + Resources: []string{ + "ovirtvolumepopulators", + "openstackvolumepopulators", + }, + Verbs: []string{ + "*", + }, + }, } } @@ -107,6 +124,20 @@ func getViewPolicyRules() []rbacv1.PolicyRule { "watch", }, }, + { + APIGroups: []string{ + "forklift.cdi.kubevirt.io", + }, + Resources: []string{ + "ovirtvolumepopulators", + "openstackvolumepopulators", + }, + Verbs: []string{ + "get", + "list", + "watch", + }, + }, { APIGroups: []string{ "cdi.kubevirt.io", @@ -137,6 +168,20 @@ func createConfigReaderClusterRole(name string) *rbacv1.ClusterRole { "watch", }, }, + { + APIGroups: []string{ + "forklift.cdi.kubevirt.io", + }, + Resources: []string{ + "ovirtvolumepopulators", + "openstackvolumepopulators", + }, + Verbs: []string{ + "get", + "list", + "watch", + }, + }, } return utils.ResourceBuilder.CreateClusterRole(name, rules)