To resolve these issues, Kubernetes provides another API Object called StorageClass
. With StorageClass
, Kubernetes is able to interact with the cloud provider directly. This allows Kubernetes to provision new storage volumes, and create PersistentVolumes
automatically.
Basically, a PersistentVolume
is a representation of a piece of storage, whereas StorageClass
is a specification of how to create PersistentVolumes
dynamically. StorageClass
abstracts the manual processes into a set of fields you can specify inside a manifest file.
For example, if you want to create a StorageClass
that will create Amazon EBS Volume of type General Purpose SSD (gp2
), you'd define a StorageClass manifest like so:
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: standard provisioner: kubernetes.io/aws-ebs parameters: type: gp2 reclaimPolicy: Retain
Here's what each field means (required fields are marked with an asterik (*
...