-
Notifications
You must be signed in to change notification settings - Fork 1.8k
CNV-56853: Add RBAC permissions to allow users to manage VMs through the web console #101259
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
Merged
+153
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
modules/virt-configure-rbac-console-subresources-api.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * virt/managing_vms/virt-controlling-vm-states.adoc | ||
|
|
||
| :_mod-docs-content-type: PROCEDURE | ||
| [id="virt-configure-rbac-console-subresources-api_{context}"] | ||
| = Configuring RBAC permissions for managing VM states by using the web console | ||
|
|
||
| [role="_abstract"] | ||
| To allow users to manage virtual machine (VM) states by using the {product-title} web console, you must create an RBAC cluster role and cluster role binding. | ||
| The cluster role uses the `subresources.kubevirt.io` API to define which resources can be controlled by certain users or groups. | ||
|
|
||
| .Prerequisites | ||
|
|
||
| * You have cluster administrator access to an {product-title} cluster where {VirtProductName} is installed. | ||
| * You have installed the {oc-first}. | ||
|
|
||
| .Procedure | ||
|
|
||
| . Create a `ClusterRole` object that allows the target user or group to manage VM states: | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: vm-manager-access | ||
| rules: | ||
| - apiGroups: | ||
| - subresources.kubevirt.io | ||
| resources: | ||
| - virtualmachines/start | ||
| - virtualmachines/stop | ||
| verbs: | ||
| - put | ||
| # ... | ||
| ---- | ||
|
|
||
| . Run the following command to apply the cluster role: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc apply -f <filename>.yaml | ||
| ---- | ||
|
|
||
| . Confirm that the cluster role was created by running the following command and observing the output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc get clusterrole <name> | ||
| ---- | ||
| + | ||
| Example output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| NAME AGE | ||
| vm-manager-access 15s | ||
| ---- | ||
|
|
||
| . Inspect the details of the cluster role, and ensure the intended rules for `subresources.kubevirt.io` are present, specifically the `virtualmachines/start` and `virtualmachines/stop` subresources. | ||
| + | ||
| Run the following command and observe the output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc describe clusterrole <name> | ||
| ---- | ||
| + | ||
| Example output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| Name: vm-manager-access | ||
| Labels: <none> | ||
| Annotations: <none> | ||
| PolicyRule: | ||
| Resources Non-Resource URLs Resource Names Verbs | ||
| --------- ----------------- -------------- ----- | ||
| virtualmachines/start, virtualmachines/stop with subresources.kubevirt.io group [] [] [put] | ||
abrennan89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ---- | ||
|
|
||
| . Create a `ClusterRoleBinding` object to bind the cluster role you have created to the target user or group: | ||
| + | ||
| [source,yaml,subs="attributes+"] | ||
| ---- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: vm-manager-access-binding | ||
| subjects: | ||
| - kind: User | ||
| name: test-user | ||
| apiGroup: rbac.authorization.k8s.io | ||
| roleRef: | ||
| kind: ClusterRole | ||
| name: vm-manager-access | ||
| apiGroup: rbac.authorization.k8s.io | ||
| ---- | ||
|
|
||
| . Run the following command to apply the cluster role binding: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc apply -f <filename>.yaml | ||
| ---- | ||
|
|
||
| . Confirm that the cluster role binding was created by running the following command and observing the output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc get clusterrolebinding <name> | ||
| ---- | ||
| + | ||
| Example output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| NAME AGE | ||
| vm-manager-access-binding 15s | ||
| ---- | ||
|
|
||
| .Verification | ||
|
|
||
| . Check if the user can start a VM by running the following command: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc auth can-i update virtualmachines/start --namespace=<namespace> --as=<user_name> --subresource=subresources.kubevirt.io | ||
| ---- | ||
| + | ||
| Example output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| yes | ||
| ---- | ||
|
|
||
| . Check if the user can stop a VM by running the following command: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc auth can-i update virtualmachines/stop --namespace=<namespace> --as=<user_name> --group=subresources.kubevirt.io | ||
| ---- | ||
| + | ||
| Example output: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| yes | ||
| ---- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.