Storage classes
Amazon EKS clusters that were created prior to Kubernetes version 1.11
weren't created with any
storage classes. You must define storage classes for your cluster to use and you should
define a default storage class for your persistent volume claims. For more information, see
Storage
classes
The in-tree Amazon EBS storage provisioner1.23
, then you must first install the Amazon EBS driver before updating your cluster. For more
information, see Amazon EBS CSI migration frequently asked
questions.
To create an Amazon storage class for your Amazon EKS cluster
-
Determine which storage classes your cluster already has.
kubectl get storageclass
The example output is as follows.
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 34m
If your cluster returns the previous output, then it already has the storage class defined in the remaining steps. You can define other storage classes using the steps for deploying any of the CSI drivers in the Storage chapter. Once deployed, you can set one of the storage classes as your default storage class.
-
Create an Amazon storage class manifest file for your storage class. The following
gp2-storage-class.yaml
example defines a storage class calledgp2
that uses the Amazon EBSgp2
volume type.For more information about the options available for Amazon storage classes, see Amazon EBS
in the Kubernetes documentation. kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: gp2 annotations: storageclass.kubernetes.io/is-default-class: "true" provisioner: kubernetes.io/aws-ebs parameters: type: gp2 fsType: ext4
-
Use
kubectl
to create the storage class from the manifest file.kubectl create -f gp2-storage-class.yaml
The example output is as follows.
storageclass "gp2" created
To define a default storage class
-
List the existing storage classes for your cluster. A storage class must be defined before you can set it as a default.
kubectl get storageclass
The example output is as follows.
NAME PROVISIONER AGE gp2 kubernetes.io/aws-ebs 8m
-
Choose a storage class and set it as your default by setting the
storageclass.kubernetes.io/is-default-class=true
annotation.kubectl annotate storageclass gp2 storageclass.kubernetes.io/is-default-class=true
The example output is as follows.
storageclass "gp2" patched
-
Verify that the storage class is now set as default.
kubectl get storageclass
The example output is as follows.
gp2 (default) kubernetes.io/aws-ebs 12m