Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forklift: add missing rbac #3320

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/operator/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1934,5 +1934,13 @@ func createNotReadyEventValidationMap() map[string]bool {
match[normalCreateSuccess+" *v1.Secret cdi-uploadserver-client-cert"] = false
match[normalCreateSuccess+" *v1.Service cdi-prometheus-metrics"] = false
match[normalCreateEnsured+" SecurityContextConstraint exists"] = false

// Forklift
match[normalCreateSuccess+" *v1.ClusterRole forklift.cdi.kubevirt.io:admin"] = false
match[normalCreateSuccess+" *v1.ClusterRole forklift.cdi.kubevirt.io:edit"] = false
match[normalCreateSuccess+" *v1.ClusterRole forklift.cdi.kubevirt.io:view"] = false
match[normalCreateSuccess+" *v1.ClusterRole forklift.cdi.kubevirt.io:config-reader"] = false
match[normalCreateSuccess+" *v1.ClusterRoleBinding forklift.cdi.kubevirt.io:config-reader"] = false

return match
}
16 changes: 2 additions & 14 deletions pkg/operator/resources/cluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ func getControllerClusterPolicyRules() []rbacv1.PolicyRule {
"get",
},
},
// "*" permissions are usually bad, but it makes sense for CDI to have them as it controls everything related
{
APIGroups: []string{
"cdi.kubevirt.io",
"forklift.cdi.kubevirt.io",
},
Resources: []string{
"*",
Expand Down Expand Up @@ -266,20 +268,6 @@ func getControllerClusterPolicyRules() []rbacv1.PolicyRule {
"update",
},
},
{
APIGroups: []string{
"forklift.cdi.kubevirt.io",
},
Resources: []string{
"ovirtvolumepopulators",
"openstackvolumepopulators",
},
Verbs: []string{
"get",
"list",
"watch",
},
},
}
}

Expand Down
31 changes: 31 additions & 0 deletions pkg/operator/resources/cluster/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}

Expand Down Expand Up @@ -75,6 +80,18 @@ func getAdminPolicyRules() []rbacv1.PolicyRule {
"*",
},
},
{
APIGroups: []string{
"forklift.cdi.kubevirt.io",
},
Resources: []string{
"ovirtvolumepopulators",
"openstackvolumepopulators",
},
Verbs: []string{
"*",
},
},
}
}

Expand Down Expand Up @@ -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",
Expand Down