Storage Classes and Dynamic Provisioning
Look at storage classes’ YAMLs and how to implement them.
We'll cover the following...
Storage classes are resources in the storage.k8s.io/v1
API group. The resource type is StorageClass, and we define them in regular YAML files. We can use the sc
short name when using kubectl
.
Note: We can run a
kubectl api-resources
command to see a full list of API resources and their short names. It also shows each resource’s API group and what its equivalentkind
is.
As the name suggests, StorageClasses let us define different classes of storage that apps can request. How we define our StorageClasses is up to us and will depend on the types of storage we have available. For example, if we have a storage system with fast and slow storage, as well as optional remote replication, we might define these four classes:
fast-local
fast-replicated
slow-local
slow-replicated
Let’s look at an example.
A StorageClass YAML
The following YAML defines a StorageClass object called fast-local
that will provision encrypted SSD volumes capable of 10 IOPs per gigabyte from the Ireland AWS region.
kind: StorageClassapiVersion: storage.k8s.io/v1metadata:name: fast-localprovisioner: ebs.csi.aws.com <<==== AWS Elastic Block Store CSI pluginparameters:encrypted: true <<==== Create encrypted volumestype: io1 <<==== AWS SSD drivesiopsPerGB: "10" <<==== Performance requirementallowedTopologies: <<==== Where to provision volumes and replicas- matchLabelExpressions:- key: topology.ebs.csi.aws.com/zonevalues:- eu-west-1a <<==== Ireland AWS region
As with all Kubernetes YAML files, kind
and ...