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-creating-storage-class.adoc
2020-11-11 20:41:24 +00:00

54 lines
1.6 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
[id="virt-creating-storage-class_{context}"]
= Creating a `StorageClass` object
When you create a `StorageClass` object, you set parameters that affect the
dynamic provisioning of PersistentVolumes (PVs) that belong to that storage class. +
[NOTE]
====
You cannot update a `StorageClass` object's parameters after you create it.
====
.Procedure
. Create a YAML file for defining the storage class. For example:
+
[source,terminal]
----
$ touch storageclass.yaml
----
. Edit the file. For example:
+
[source,yaml]
----
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: hostpath-provisioner <1>
provisioner: kubevirt.io/hostpath-provisioner
reclaimPolicy: Delete <2>
volumeBindingMode: WaitForFirstConsumer <3>
----
<1> You can optionally rename the storage class by changing this value.
<2> The two possible `reclaimPolicy` values are `Delete` and `Retain`. If you
do not specify a value, the storage class defaults to `Delete`.
<3> The `volumeBindingMode` value determines when dynamic provisioning and volume
binding occur. Specify `WaitForFirstConsumer` to delay the binding and provisioning
of a PV until after a Pod that uses the PersistentVolumeClaim (PVC)
is created. This ensures that the PV meets the Pod's scheduling requirements.
. Create the `StorageClass` object:
+
[source,terminal]
----
$ oc create -f storageclass.yaml
----
.Additional information
* link:https://kubernetes.io/docs/concepts/storage/storage-classes/[Storage Classes]