mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
58 lines
2.5 KiB
Plaintext
58 lines
2.5 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/storage/virt-configuring-local-storage-with-hpp.adoc
|
|
// * virt/post_installation_configuration/virt-post-install-storage-config.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-creating-storage-class-csi-driver_{context}"]
|
|
= Creating a storage class for the CSI driver with the storagePools stanza
|
|
|
|
[role="_abstract"]
|
|
To use the hostpath provisioner (HPP) you must create an associated storage class for the Container Storage Interface (CSI) driver.
|
|
|
|
When you create a storage class, you set parameters that affect the dynamic provisioning of persistent volumes (PVs) that belong to that storage class. You cannot update a `StorageClass` object's parameters after you create it.
|
|
|
|
[NOTE]
|
|
====
|
|
Virtual machines use data volumes that are based on local PVs. Local PVs are bound to specific nodes. While a disk image is prepared for consumption by the virtual machine, it is possible that the virtual machine cannot be scheduled to the node where the local storage PV was previously pinned.
|
|
|
|
To solve this problem, use the Kubernetes pod scheduler to bind the persistent volume claim (PVC) to a PV on the correct node. By using the `StorageClass` value with `volumeBindingMode` parameter set to `WaitForFirstConsumer`, the binding and provisioning of the PV is delayed until a pod is created using the PVC.
|
|
====
|
|
|
|
ifdef::openshift-rosa,openshift-dedicated[]
|
|
.Prerequisites
|
|
|
|
* Install the {oc-first}.
|
|
* Log in as a user with `cluster-admin` privileges.
|
|
endif::openshift-rosa,openshift-dedicated[]
|
|
|
|
.Procedure
|
|
|
|
. Create a `storageclass_csi.yaml` file to define the storage class:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: storage.k8s.io/v1
|
|
kind: StorageClass
|
|
metadata:
|
|
name: hostpath-csi
|
|
provisioner: kubevirt.io.hostpath-provisioner
|
|
reclaimPolicy: Delete <1>
|
|
volumeBindingMode: WaitForFirstConsumer <2>
|
|
parameters:
|
|
storagePool: my-storage-pool <3>
|
|
----
|
|
+
|
|
* `reclaimPolicy` specifies whether the underlying storage is deleted or retained when a user deletes a PVC. The two possible `reclaimPolicy` values are `Delete` and `Retain`. If you do not specify a value, the default value is `Delete`.
|
|
* `volumeBindingMode` specifies the timing of PV creation. The `WaitForFirstConsumer` configuration in this example means that PV creation is delayed until a pod is scheduled to a specific node.
|
|
* `parameters.storagePool` specifies the name of the storage pool defined in the HPP custom resource (CR).
|
|
|
|
. Save the file and exit.
|
|
|
|
. Create the `StorageClass` object by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f storageclass_csi.yaml
|
|
----
|