How to Provision Persistent Volume Claims on Vultr Kubernetes Engine

Updated on April 22, 2024
How to Provision Persistent Volume Claims on Vultr Kubernetes Engine header image

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:

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.
  • 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

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.

  1. Create a configuration file.

    console
    $ nano create_pvc.yaml
    
  2. Copy and paste the below given configuration.

    yaml
    apiVersion: 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 the storage field.

    Similarly, if you want to request an HDD block storage you can use the following configurations.

    yaml
    apiVersion: 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 to vultr-block-storage-hdd.

  3. Apply the configuration file.

    console
    $ sudo kubectl apply -f create_pvc.yaml
    

    Output

    output
    persistentvolumeclaim/csi-pvc created
    
  4. Verify that a new block storage is provisioned.

    console
    $ sudo kubectl get pvc
    

    Output

    output
    NAME      STATUS   VOLUME                 CAPACITY   ACCESS MODES   STORAGECLASS          VOLUMEATTRIBUTESCLASS   AGE
    csi-pvc   Bound    pvc-36bbc0eb476040a9   10Gi       RWO            vultr-block-storage   <unset>                 56s
    
  5. You can verify the same by navigating to Cloud Storage then Block Storage on your Vultr Customer Portal.

    PVC provision

PVC Expansion

In this section, you are to expand the storage capacity of an existing block storage attached to your instance.

  1. Change the configuration file.

    console
    $ nano create_pvc.yaml
    
  2. Increase the storage capacity.

    yaml
    apiVersion: 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.

  3. Apple the configuration changes.

    console
    $ sudo kubectl apply -f create_pvc.yaml
    

    Output

    output
    persistentvolumeclaim/csi-pvc configured
    
  4. Verify the change.

    console
    $ sudo kubectl get pvc
    

    Output

    output
    NAME      STATUS   VOLUME                 CAPACITY   ACCESS MODES   STORAGECLASS          VOLUMEATTRIBUTESCLASS   AGE
    csi-pvc   Bound    pvc-36bbc0eb476040a9   30Gi       RWO            vultr-block-storage   <unset>                 5m1s
    
  5. You can verify the same by navigating to Cloud Storage then Block Storage on your Vultr portal.

    PVC Expansion

  6. 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.