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 (*):
- apiVersion: The StorageClass object is provided in the storage.k8s.io API group.
- *provisioner: The name of a provisioner that would prepare new storage spaces on-demand. For instance, if a Pod requests 10 GB of block storage from the standard StorageClass, then the kubernetes.io/aws-ebs provisioner will interact directly with AWS to create a new storage volume of at least 10 GB in size.
- *parameters: The parameters that are passed to the provisioner so it knows how to provision the storage. Valid parameters depends on the provisioner. For example, both kubernetes.io/aws-ebs and kubernetes.io/gce-pd support the type parameter.
- *reclaimPolicy: As with PersistentVolumes, the Reclaim Policy determines whether the data written to the storage media is retained or deleted. This can be either Delete or Retain, but it defaults to Delete.
There are many types of provisioners available. Amazon EBS provisions Block storage on AWS, but there are other types of storage, namely file and object storage. We will be using block storage here because it provides the lowest latency, and is suitable for use with our Elasticsearch database.