How to Provision Persistent Volume Claims on Vultr Kubernetes Engine
Introduction
Vultr Kubernetes Engine (VKE) comes with a managed Kubernetes control plane that automatically deploys Vultr Container Storage Interface (CSI) to connect the Kubernetes cluster with Vultr's high-speed block storage by default and help your applications scale easily.
In this guide, you are to provision Vultr Block Storage and edit the configuration to perform PVC expansion.
Prerequisites
Before you begin:
- Deploy a Vultr Ubuntu server
- Deploy a Vultr Kubernetes Engine (VKE) cluster with at least 2 nodes.
- Access the workstation using SSH as a non-root user with sudo privileges.
- Install and configure Kubectl to access the cluster.
Understanding Storage Classes
Vultr offers two kinds of block storage technologies available in almost all locations available globally.
HDD Block Storage - An affordable option that uses traditional rotating hard drives and supports volumes larger than 10 TB.
- CSI Storage Class:
vultr-block-storage-hdd
- Minimum volume size: 40 GB
- Maximum volume size: 40 TB
- Technology: Rotating hard disk drive
- Availability: Most Vultr locations
- Key Feature: Affordable storage and largest volumes.
- CSI Storage Class:
NVMe Block Storage - A higher-performance option for workloads that require rapid I/O.
- CSI Storage Class:
vultr-block-storage
- Minimum volume size: 10 GB
- Maximum volume size: 10 TB
- Technology: Solid-state NVMe
- Availability: Many Vultr locations
- Key Feature: Highest performance I/O
- CSI Storage Class:
To check the block storage availability in your region use the /v2/regions
API endpoint to discover which storage classes are available at your location.
block_storage_storage_opt
indicates HDD storage is available.
block_storage_high_perf
indicates NVMe storage is available.
Some locations support both storage classes. If NVMe block storage is available in a location, our CSI uses that class by default.
Create Persistent Volume Claims (PVCs)
In this section, you are to create a PVC using a YAML configuration file.
Create a configuration file.
console$ nano create_pvc.yaml
Copy and paste the below given configuration.
yamlapiVersion: v1 kind: PersistentVolumeClaim metadata: name: csi-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: vultr-block-storage
Save and exit the file.
In the above configuration, you are requesting an NVMe block storage with the
storageClassName
that has 10GB storage by defining thestorage
field.Similarly, if you want to request an HDD block storage you can use the following configurations.
yamlapiVersion: v1 kind: PersistentVolumeClaim metadata: name: csi-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 40Gi storageClassName: vultr-block-storage-hdd
In the above configuration storage is changed to 40 GB as the minimum volume size for an HDD block storage is 40 GB and the
storageClassName
tovultr-block-storage-hdd
.Apply the configuration file.
console$ sudo kubectl apply -f create_pvc.yaml
Output
outputpersistentvolumeclaim/csi-pvc created
Verify that a new block storage is provisioned.
console$ sudo kubectl get pvc
Output
outputNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE csi-pvc Bound pvc-36bbc0eb476040a9 10Gi RWO vultr-block-storage <unset> 56s
You can verify the same by navigating to Cloud Storage then Block Storage on your Vultr Customer Portal.
PVC Expansion
In this section, you are to expand the storage capacity of an existing block storage attached to your instance.
Change the configuration file.
console$ nano create_pvc.yaml
Increase the storage capacity.
yamlapiVersion: v1 kind: PersistentVolumeClaim metadata: name: csi-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 30Gi storageClassName: vultr-block-storage
Save and exit the file.
In the above configuration, you increased the storage capacity for an existing NVMe block storage to 30 GB from the original 10 GB.
Apple the configuration changes.
console$ sudo kubectl apply -f create_pvc.yaml
Output
outputpersistentvolumeclaim/csi-pvc configured
Verify the change.
console$ sudo kubectl get pvc
Output
outputNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE csi-pvc Bound pvc-36bbc0eb476040a9 30Gi RWO vultr-block-storage <unset> 5m1s
You can verify the same by navigating to Cloud Storage then Block Storage on your Vultr portal.
It is not advised to reduce the storage capacity of the block storage as the action may result in significant data loss.
Conclusion
In this guide, you learned different Block Storage types and classes available globally on Vultr, you provisioned an HDD block storage and you also explored how to expand the storage of an existing block storage attached to the instance.