mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
71 lines
2.4 KiB
Plaintext
71 lines
2.4 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
|
|
|
|
:_content-type: PROCEDURE
|
|
[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 persistent volumes (PVs) that the hostpath provisioner creates.
|
|
+
|
|
[IMPORTANT]
|
|
====
|
|
The backing directory must not be located in the filesystem's root directory because the `/` partition is read-only on {op-system-first}. For example, you can use `/var/<directory_name>` but not `/<directory_name>`.
|
|
====
|
|
|
|
* 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 <backing_directory_path>
|
|
----
|
|
+
|
|
[NOTE]
|
|
====
|
|
If you use {op-system-first} 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: "<backing_directory_path>" <1>
|
|
useNamingPrefix: false <2>
|
|
workload: <3>
|
|
----
|
|
<1> Specify the backing directory where you want the provisioner to create PVs. This directory must not be located in the filesystem's root directory (`/`).
|
|
<2> Change this value to `true` if you want to use the name of the persistent volume claim (PVC) that is bound to the created PV as the prefix of the directory name.
|
|
<3> Optional: You can use the `spec.workload` field to configure node placement rules for the hostpath provisioner.
|
|
+
|
|
[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
|
|
----
|