StorageClass CreationΒΆ
MetalK8s uses StorageClass objects to describe how volumes are formatted and mounted. This topic explains how to use the CLI to create a StorageClass.
Create a StorageClass manifest.
You can define a new StorageClass using the following template:
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: <storageclass_name> provisioner: kubernetes.io/no-provisioner reclaimPolicy: Retain volumeBindingMode: WaitForFirstConsumer mountOptions: - rw parameters: fsType: <filesystem_type> mkfsOptions: <mkfs_options>
Set the following fields:
mountOptions
: specifies how the volume should be mounted. For example:rw
(read/write), orro
(read-only).fsType
: specifies the filesystem to use on the volume.xfs
andext4
are the only currently supported file system types.mkfsOptions
: specifies how the volume should be formatted. This field is optional (note that the options are passed as a JSON-encoded string). For example'["-m", "0"]'
could be used asmkfsOptions
for anext4
volume.Set
volumeBindingMode
asWaitForFirstConsumer
in order to delay the binding and provisioning of a Pod until a Pod using the PersistentVolumeClaim is created.
Create the StorageClass.
root@bootstrap $ kubectl apply -f storageclass.yml
Check that the StorageClass has been created.
root@bootstrap $ kubectl get storageclass <storageclass_name> NAME PROVISIONER AGE <storageclass_name> kubernetes.io/no-provisioner 2s