2 min read | by Jordi Prats
If you have an existing EBS volume that you want to use on your EKS cluster, or you don't want to let Kubernetes to manage your volumes, you can use awsElasticBlockStore to link an existing EBS volume to a PersistentVolume or use it directly as a volume on a pod spec:
If we want to use a PersistentVolume object we will have to create using the following spec, adjusting it's size and volumeID:
kind: PersistentVolume apiVersion: v1 metadata: name: test-ebs spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce awsElasticBlockStore: volumeID: vol-0f188b7fd87c91a7e fsType: ext4
But we can also mount it directly into a pod as a volume:
apiVersion: v1 kind: Pod metadata: name: demo-pod-ebs-volume spec: containers: - image: k8s.gcr.io/test-webserver name: test-container volumeMounts: - mountPath: /test-ebs name: ebs-volume volumes: - name: ebs-volume awsElasticBlockStore: volumeID: vol-0f188b7fd87c91a7e fsType: ext4
This can also be used on any object containing a pod spec template, such as Deployment, DaemonSet, Job...
By manually managing EBS volumes we are going to give away the automatic provision and automatic Volume resizing, nevertheless it is still possible.
Posted on 24/05/2021