Creating a storage class for vSphere volume
Create a storage class to provide PersistentVolume on a vSphere datastore.
Required user type or access level: Cluster administrator
Prerequisites
IBM® Cloud Private must be configured with a vSphere Cloud Provider. See Configuring a vSphere Cloud Provider.
Create a storage class
To create a storage class for a vSphere volume, specify the following field values in the storage class definition:
- metadata:
name
: Name of the storage class object.
- parameters:
diskformat
:thin
,zeroedthick
, oreagerzeroedthick
.datastore
: Name of the datastore. The volume is created on the datastore that is specified in the storage class.storagePolicyName
: Name of the storage policy that you created in your vSphere setup. A persistent volume (PV) is dynamically provisioned based on the storage policy. For more information about storage policy based management (SPBM), see Storage Policy Based Management for dynamic provisioning of volumes .
Following is an example of how to create a storage class:
-
Create a
YAML
file with the storage class definitions:vim vsphere-volume-storage-class-1.yaml
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: storage-class-1 provisioner: kubernetes.io/vsphere-volume parameters: diskformat: thin datastore: datastore-1 storagePolicyName: vsanStoragePolicy
-
Create the storage class:
kubectl create -f vsphere-volume-storage-class-1.yaml
The output resembles the following code:
storageclass "storage-class-1" created
-
Verify that the storage class is created:
kubectl describe sc storage-class-1
The output resembles the following code:
Name: storage-class-1 IsDefaultClass: No Annotations: <none> Provisioner: kubernetes.io/vsphere-volume Parameters: datastore=datastore-1,diskformat=thin,storagePolicyName=vsanStoragePolicy Events: <none>