Dynamic Volume Provisioning allows storage volumes to be created on-demand. StorageClass should be pre-created to define which provisioner should be used and what parameters should be passed when dynamic provisioning is invoked.
Copy/Paste the following commands into your Cloud9 Terminal.
cat << EoF > ${HOME}/environment/ebs_statefulset/mysql-storageclass.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: mysql-gp2
provisioner: ebs.csi.aws.com # Amazon EBS CSI driver
parameters:
type: gp2
encrypted: 'true' # EBS volumes will always be encrypted by default
reclaimPolicy: Delete
mountOptions:
- debug
EoF
You can see that:
ebs.csi.aws.com
.encrypted
parameter will ensure the EBS volumes are encrypted by default.Create storageclass mysql-gp2
by following command.
kubectl create -f ${HOME}/environment/ebs_statefulset/mysql-storageclass.yaml
You can verify the StorageClass and its options with this command.
kubectl describe storageclass mysql-gp2
We will specify mysql-gp2
as the storageClassName in volumeClaimTemplates at “Create StatefulSet” section later.