How to dynamically create EBS volume with Kubernetes Persistence Volume

9/12/2017

I'm aware you can use aws cli to create ebs volume and then get the Volume ID and add to PersistentVolume config as below under the volumeID.

I don't want to use aws cli to create the ebs volume, My question is, how do I use Kubernetes to create this ebs volume dynamically without using the cli ?

apiVersion: "v1"
kind: "PersistentVolume"
metadata:
  name: "pv0001" 
spec:
  capacity:
    storage: "5Gi" 
  accessModes:
    - "ReadWriteOnce"
  awsElasticBlockStore: 
    fsType: "ext4" 
    volumeID: "volume-ID" 
-- Innocent Anigbo
kubernetes

3 Answers

5/14/2019

Follow this: https://docs.docker.com/ee/ucp/kubernetes/storage/configure-aws-storage/

Basically, instances must have an IAM Role to create/attach/detach/delete volumes on their own.

-- Alberto Massidda
Source: StackOverflow

9/13/2017

Dynamic provisioning

When none of the static PVs the administrator created matches a user’s PersistentVolumeClaim, the cluster may try to dynamically provision a volume specially for the PVC. This provisioning is based on StorageClasses: the PVC must request a class and the administrator must have created and configured that class in order for dynamic provisioning to occur. Claims that request the class "" effectively disable dynamic provisioning for themselves

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#provisioning

-- Innocent Anigbo
Source: StackOverflow

9/12/2017

By default this should be working on a decently provisioned cluster. Just have the storageClassName defined correctly on a matching PVC and a PV will et provisioned for it (no need to precreate PV object, just the claim)

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims

-- Radek 'Goblin' Pieczonka
Source: StackOverflow