Persistent Volumes

Working with Persistent Volumes

Thalassa Cloud provides Persistent Volumes (PVs) to enable stateful workloads in Kubernetes. A Persistent Volume is a piece of storage provisioned for applications, independent of the pod lifecycle. This ensures that data persists even if a pod is restarted, rescheduled, or deleted.

Persistent Volumes in Thalassa Cloud are managed using StorageClasses that define how storage is dynamically allocated and provisioned. The default storage class for block storage is block, optimized for high performance and reliability.

Available Storage Classes

A StorageClass in Kubernetes defines how Persistent Volumes are dynamically provisioned. In Thalassa Cloud, the default storage class is named block, backed by NVMe-based block storage for optimal performance.

To list available storage classes in your cluster, run:

kubectl get storageclass

If no storage classes are available, ensure that the CSI storage driver is enabled and properly configured for your environment.

Creating a Persistent Volume Claim (PVC)

To request storage for a workload, you need to create a Persistent Volume Claim (PVC). A PVC dynamically provisions a Persistent Volume from an available StorageClass.

Example: Defining a PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-volume
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: block
  resources:
    requests:
      storage: 10Gi

Apply the PVC definition:

kubectl apply -f pvc.yaml

Checking PVC Status

To check if the Persistent Volume is bound to your PVC:

kubectl get pvc -A

Example output:

NAMESPACE   NAME        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
default     my-volume   Bound    pvc-12345678-abcd-efgh-ijkl-9876543210ab   10Gi       RWO            block          5m

A Bound status confirms that the volume is ready for use.

Using Persistent Volumes in Deployments

Once a PVC is created, it can be referenced in pods or deployments to mount storage.

Example: Attaching a PVC to a Pod

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  namespace: default
spec:
  containers:
  - name: my-container
    image: busybox
    volumeMounts:
    - mountPath: "/data"
      name: storage
  volumes:
  - name: storage
    persistentVolumeClaim:
      claimName: my-volume

Apply the deployment:

kubectl apply -f pod.yaml

This pod will have access to the persistent storage under /data.

Resizing a Persistent Volume

Persistent Volumes in Thalassa Cloud support dynamic resizing if the storage class allows expansion.

To resize a PVC, edit the resources.requests.storage value:

spec:
  resources:
    requests:
      storage: 20Gi

Apply the updated PVC definition:

kubectl apply -f pvc.yaml

Checking Resizing Status

kubectl get pvc my-volume -o yaml | grep capacity

If resizing is supported, the new capacity will be reflected once the update is completed.

Deleting a Persistent Volume Claim

To delete a PVC and free up the associated storage:

kubectl delete pvc my-volume

Ensure that no workloads are using the volume before deletion.

Summary

Persistent Volumes in Thalassa Cloud Kubernetes enable stateful applications by providing durable, high-performance storage that remains independent of the pod lifecycle. Users can dynamically provision storage using StorageClasses, manage Persistent Volume Claims, and expand storage as needed.

Additional Resources