Skip to content

Commit

Permalink
fix: Allow kubevirt:default clusterRole to get,list kubevirts
Browse files Browse the repository at this point in the history
Kubevirt resource is in category all.
`kubectl get all` or `virtctl permitted-devices` fails if
the user don't have the permissions to list Kubevirt resource.

Signed-off-by: fossedihelm <[email protected]>
  • Loading branch information
fossedihelm committed Jan 11, 2024
1 parent afef58c commit ed28ff5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions manifests/generated/operator-csv.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,13 @@ spec:
- get
- list
- watch
- apiGroups:
- kubevirt.io
resources:
- kubevirts
verbs:
- get
- list
- apiGroups:
- subresources.kubevirt.io
resources:
Expand Down
7 changes: 7 additions & 0 deletions manifests/generated/rbac-operator.authorization.k8s.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@ rules:
- get
- list
- watch
- apiGroups:
- kubevirt.io
resources:
- kubevirts
verbs:
- get
- list
- apiGroups:
- subresources.kubevirt.io
resources:
Expand Down
11 changes: 11 additions & 0 deletions pkg/virt-operator/resource/generate/rbac/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ func newDefaultClusterRole() *rbacv1.ClusterRole {
},
},
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{
GroupName,
},
Resources: []string{
ApiKubevirts,
},
Verbs: []string{
"get", "list",
},
},
{
APIGroups: []string{
virtv1.SubresourceGroupName,
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-operator/resource/generate/rbac/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var _ = Describe("Cluster role and cluster role bindings", func() {
expectExactRuleExists(clusterRole.Rules, apiGroup, resource, verbs...)

},
Entry(fmt.Sprintf("get and list %s/%s", GroupName, ApiKubevirts), GroupName, ApiKubevirts, "get", "list"),
Entry(fmt.Sprintf("get and list %s/%s", virtv1.SubresourceGroupName, ApiVersion), virtv1.SubresourceGroupName, ApiVersion, "get", "list"),
Entry(fmt.Sprintf("get and list %s/%s", virtv1.SubresourceGroupName, ApiGuestFs), virtv1.SubresourceGroupName, ApiGuestFs, "get", "list"),
)
Expand Down

0 comments on commit ed28ff5

Please sign in to comment.