1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/virt-using-hostpath-provisioner.adoc

71 lines
2.0 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
[id="virt-using-hostpath-provisioner_{context}"]
= Using the hostpath provisioner to enable local storage
To deploy the hostpath provisioner and enable your virtual machines to use local
storage, first create a HostPathProvisioner custom resource.
.Prerequisites
* Create a backing directory on each node for the PersistentVolumes (PVs)
that the hostpath provisioner creates.
* Apply the SELinux context `container_file_t` to the PV
backing directory on each node. For example:
+
[source,terminal]
----
$ sudo chcon -t container_file_t -R </path/to/backing/directory>
----
+
[NOTE]
====
If you use Red Hat Enterprise Linux CoreOS 8 workers, you must configure SELinux
by using a MachineConfig manifest instead.
====
.Procedure
. Create the HostPathProvisioner custom resource file. For example:
+
[source,terminal]
----
$ touch hostpathprovisioner_cr.yaml
----
. Edit the file, ensuring that the `spec.pathConfig.path` value is the directory
where you want the hostpath provisioner to create PVs. For example:
+
[source,yaml]
----
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
spec:
imagePullPolicy: IfNotPresent
pathConfig:
path: "</path/to/backing/directory>" <1>
useNamingPrefix: "false" <2>
----
<1> Specify the backing directory where you want the provisioner to create PVs.
<2> Change this value to `true` if you want to use the name of the PersistentVolumeClaim (PVC)
that is bound to the created PV as the prefix of the directory name.
+
[NOTE]
====
If you did not create the backing directory, the provisioner attempts to create
it for you. If you did not apply the `container_file_t` SELinux context, this can cause
`Permission denied` errors.
====
. Create the custom resource in the `openshift-cnv` namespace:
+
[source,terminal]
----
$ oc create -f hostpathprovisioner_cr.yaml -n openshift-cnv
----