简体   繁体   English

如何使用Kubernetes Persistence Volume动态创建EBS卷

[英]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 . 我知道您可以使用aws cli创建ebs卷,然后获取卷ID并按以下方式在volumeID下添加到PersistentVolume配置。

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 ? 我不想使用aws cli创建ebs卷,我的问题是,如何在不使用cli的情况下如何使用Kubernetes动态创建该ebs卷?

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) 只需在匹配的PVC上正确定义storageClassName即可为其设置PV(无需预先创建PV对象,只需声明)

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims 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. 当管理员创建的所有静态PV均与用户的PersistentVolumeClaim匹配时,群集可能会尝试动态地为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. 此设置基于StorageClasses :PVC必须请求一个类,并且管理员必须已经创建并配置了该类,才能进行动态设置。 Claims that request the class "" effectively disable dynamic provisioning for themselves 要求类""实际上为其自身禁用了动态预配置

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

Follow this: https://docs.docker.com/ee/ucp/kubernetes/storage/configure-aws-storage/ 请遵循以下步骤: 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. 基本上,实例必须具有IAM角色才能自行创建/附加/分离/删除卷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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