...

/

Provision Volume Using an Existing StorageClass

Provision Volume Using an Existing StorageClass

Learn how we can dynamically provision a volume using an existing StorageClass.

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: data
Playground

Use 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 sc
RECLAIM
NAME PROVISIONER POLICY VOLUMEBINDINGMODE
enterprise-multi.. filestore.csi.storage.gke.io Delete WaitForFirstConsumer
enterprise-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumer
premium-rwo pd.csi.storage.gke.io Delete WaitForFirstConsumer
premium-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumer
standard kubernetes.io/gce-pd Delete Immediate
standard-rwo (def) pd.csi.storage.gke.io Delete WaitForFirstConsumer
standard-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumer
zonal-rwx filestore.csi.storage.gke.io Delete WaitForFirstConsumer
Get all StorageClasses

Precreated StorageClasses

Let’s examine the output.

First up, Kubernetes created these StorageClasses ...