Let's perform the following steps to learn the storage class parameters to construct a GCE PD storage class that we can use to dynamically request new persistent volumes:
- GKE-based Kubernetes clusters are created with a default storage class. List the storage classes as follows:
$ kubectl get sc
NAME PROVISIONER AGE
standard (default) kubernetes.io/gce-pd 81s
- Describe the standard storage class:
$ kubectl describe sc standard
Name: standard
IsDefaultClass: Yes
Annotations: storageclass.beta.kubernetes.io/is-default-class=true
Provisioner: kubernetes.io/gce-pd
Parameters: type=pd-standard
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: Immediate
Events: <none>
- Create a basic storage class with the provisioner, kubernetes.io/gce-pd, and the pd-standard type specified:
$ cat <<EOF | kubectl apply -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: gce-pd
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-standard
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- us-central1-a
- us-central1-b
EOF
You can find the definition and use cases for different volume types on the GCE PD volume types link in the See also section.
On GKE clusters, the default PD volume type is pd-standard. For database workloads, such as MongoDB, Cassandra, and PostgreSQL, pd-ssd-type, high-performance SSDs are recommended.
- List the storage classes:
$ kubectl get sc
NAME PROVISIONER AGE
gce-pd kubernetes.io/gce-pd 3s
standard (default) kubernetes.io/gce-pd 17m
GKE comes with a default storage class called standard. You may have more than one storage class in your cluster. Ideally, storage classes should be created with an application's requirements in mind, since certain applications require faster volumes, while others may take advantage of multi-availability zone replication provided by other solutions.