简体   繁体   中英

How to dynamically create EBS volume with Kubernetes Persistence Volume

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" 

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM