Enabling user permissions to clone data volumes across namespaces
The isolating nature of namespaces means that users cannot by default clone resources between namespaces.
To enable a user to clone a virtual machine to another namespace, a
user with the cluster-admin role must create a new cluster role. Bind
this cluster role to a user to enable them to clone virtual machines
to the destination namespace.
Creating RBAC resources for cloning data volumes
You can create a new cluster role that enables permissions for all actions for the datavolumes resource.
-
You have installed the OpenShift CLI (
oc). -
You must have cluster admin privileges.
Note
If you are a non-admin user that is an administrator for both the source and target namespaces, you can create a Role instead of a ClusterRole where appropriate.
-
Create a
ClusterRolemanifest:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: <datavolume-cloner> rules: - apiGroups: ["cdi.kubevirt.io"] resources: ["datavolumes/source"] verbs: ["*"]- Unique name for the cluster role.
-
Create the cluster role in the cluster:
$ oc create -f <datavolume-cloner.yaml>- The file name of the
ClusterRolemanifest created in the previous step.
- The file name of the
-
Create a
RoleBindingmanifest that applies to both the source and destination namespaces and references the cluster role created in the previous step.apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: <allow-clone-to-user> namespace: <Source namespace> subjects: - kind: ServiceAccount name: default namespace: <Destination namespace> roleRef: kind: ClusterRole name: datavolume-cloner apiGroup: rbac.authorization.k8s.io- Unique name for the role binding.
- The namespace for the source data volume.
- The namespace to which the data volume is cloned.
- The name of the cluster role created in the previous step.
-
Create the role binding in the cluster:
$ oc create -f <datavolume-cloner.yaml>- The file name of the
RoleBindingmanifest created in the previous step.
- The file name of the