Provision Volume Using an Existing StorageClass
Explore how to use StorageClasses to dynamically provision persistent volumes in Kubernetes, particularly on Google Kubernetes Engine. Understand StorageClass configurations, reclaim policies, and volume binding modes to effectively manage storage in production environments. Learn to create Persistent Volume Claims and Pods that trigger volume provisioning, and verify resource lifecycle on Google Cloud.
We'll cover the following...
In this and the next lesson, we’ll use StorageClasses to dynamically provision volumes on external systems. These lessons will only work on Regional GKE clusters. Refer to the Getting Kubernetes chapter on how to create a cluster on GKE. Every cloud and storage system has its own CSI plugin and configuration options; we can’t create examples for them all. Don’t be upset if you don’t have a Regional GKE cluster; you’ll still learn a lot by reading through the demos.
Use the following widget to execute all the commands for this lesson.
apiVersion: v1
kind: Pod
metadata:
name: volpod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-prem
containers:
- name: ubuntu-ctr
image: ubuntu:latest
command:
- /bin/bash
- "-c"
- "sleep 60m"
volumeMounts:
- mountPath: /data
name: dataUse an existing StorageClass
The following command lists the precreated StorageClasses on a typical GKE Autopilot cluster. The output is trimmed, and it’s okay if the cluster has less.
$ kubectl get scRECLAIMNAME PROVISIONER POLICY VOLUMEBINDINGMODEenterprise-multi.. filestore.csi.storage.gke.io Delete WaitForFirstConsumerenterprise-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumerpremium-rwo pd.csi.storage.gke.io Delete WaitForFirstConsumerpremium-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumerstandard kubernetes.io/gce-pd Delete Immediatestandard-rwo (def) pd.csi.storage.gke.io Delete WaitForFirstConsumerstandard-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumerzonal-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumer
Precreated StorageClasses
Let’s examine the output.
First up, Kubernetes created these StorageClasses ...