简体   繁体   English

在 Kubernetes 部署中为每个 pod 附加新的 azure 磁盘卷

[英]Attach new azure disk volume per pod in Kubernetes deployment

I have a Kubernetes Deployment app with 3 replicas, which needs a 7GB storage for each replica, I want to be able to attach a new empty azureDisk storage to be mounted into each pod/replica created in this deployment.我有一个带有 3 个副本的 Kubernetes 部署应用程序,每个副本需要 7GB 存储空间,我希望能够附加一个的空azureDisk存储空间,以安装到在此部署中创建的每个 pod/副本中。

Basically I have the following restrictions:基本上我有以下限制:

  • I must use Deployment, not a Statefulset我必须使用 Deployment,而不是 Statefulset
  • Each time a pod dies and a new pod is up, it shouldn't have a state, and it will have a new empty azureDisk attached to it.每次 pod 死亡并且新 pod 启动时,它不应该有 state,它会附加一个新的空 azureDisk。
  • the pods do not share their storage, each pod has its own 7GB storage. Pod 不共享它们的存储空间,每个 Pod 都有自己的 7GB 存储空间。
  • the pods need to use azureDisk because I need a 7GB storage on demand, which means, dynamically creating azureStorage when I scale my deployment replicas. Pod 需要使用 azureDisk,因为我需要 7GB 的按需存储,这意味着,当我扩展我的部署副本时动态创建 azureStorage。

When using azureDisk, I need to use it with Access mode type ReadWriteOnce (as says in the docs ) and it will attach the only 1 pod to this disk, that's found, but, that only works if I have 1 pod, if I have more than 1 pod, I can't use the same claim... is there any way to dynamically ask for more storages like the one in the first claim?使用 azureDisk 时,我需要将它与 Access 模式类型 ReadWriteOnce 一起使用(如文档中所述),它会将唯一的 1 个 pod 附加到该磁盘,这是找到的,但是,只有当我有 1 个 pod 时才有效,如果我有超过 1 个 pod,我不能使用相同的声明...有没有办法像第一个声明中的那样动态请求更多存储空间?

NOTE 1: I know there is a volumeClaimTemplates, but that's only related to a Statefulset.注意 1:我知道有一个 volumeClaimTemplates,但这仅与 Statefulset 有关。

NOTE 2: I don't care if a pod restarts 100 times, and this in turn creates 100 PV which only 1 is used, that is fine.注意 2:我不在乎 pod 是否重新启动 100 次,这反过来又会创建 100 个 PV,而其中仅使用 1 个,这很好。

I'm not sure why you need to use a StatefulSet but the only I see to do this is to create your ownoperator for your application.我不确定您为什么需要使用 StatefulSet,但我看到的唯一做法是为您的应用程序创建自己的运算符 The operator would have a controller that manages your pods similar to what a ReplicaSet does but with the exception that for every new pod that is instantiated a new PVC is created.操作员将拥有一个 controller 来管理您的 pod,这与ReplicaSet所做的类似,但不同之处在于,对于每个实例化的新 pod,都会创建一个新的 PVC。

It might just be better to figure out how to run your application in a StatefulSet and use VolumeClaimTemplates弄清楚如何在 StatefulSet 中运行应用程序并使用VolumeClaimTemplates可能会更好

✌️ ✌️

The main question is - Why?主要问题是——为什么? "if I have an application which doesn't have state, still I need a large volume for each pod" “如果我有一个没有 state 的应用程序,我仍然需要每个 pod 的大容量”

Looking at this explanation you should focus on StateFull application.查看这个解释,您应该关注 StateFull 应用程序。 From my point of view it looks like you are forcing to use Deployment instead of StateFullSet for StateFull application从我的角度来看,您似乎正在强制对StateFull 应用程序使用 Deployment 而不是 StateFullSet

In your example probably you need pv which support different access modes .在您的示例中,您可能需要支持不同访问模式pv

The main problem you have experienced is that using pv with supported mode ReadWriteOnce you can bind at the same time only one pv by single node.您遇到的主要问题是,使用支持模式ReadWriteOnce的 pv,您只能通过单个节点同时绑定一个 pv。 So your pods in different nodes will not start due to failing volume mounting.因此,由于卷安装失败,您在不同节点中的 pod 将无法启动。 You can use this approach only for ReadOnlyMany/ReadWriteMany scenario.您只能将此方法用于ReadOnlyMany/ReadWriteMany方案。

Please refer to other providers which have different capabilities for access modes like: filestore(gcp) , AzureFile(azure) , Glusterfs, NFS请参考其他具有不同访问模式功能的提供商,例如: filestore(gcp)AzureFile(azure) 、Glusterfs、NFS

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

相关问题 有没有一种方法可以在kubernetes部署(或有状态集)中为每个Pod创建持久卷? - Is there a way to create a persistent volume per pod in a kubernetes deployment (or statefulset)? 如何将OpenStack卷连接到Kubernetes Staic Pod? - How to attach OpenStack volume to a Kubernetes staic pod? Kubernetes Azure磁盘动态持久卷声明:挂载失败,超时已过期。 Pod永远处于“ContainerCreating”状态 - Kubernetes Azure disk dynamic Persistent Volume Claim: Mount failed with timeout expired. Pod is in “ContainerCreating” status for ever 我们如何创建基于天蓝色磁盘的持久卷声明并从 Kubernetes 中的 POD 使用它们? - How can we create azure-disk based persistent volume claim and use them from a POD in Kubernetes? Kubernetes 部署持久卷和 VM 磁盘大小 - Kubernetes Deployment Persistent Volume and VM disk size Kubernetes 每个节点一个 Pod,每个 Pod 一个持久卷 - Kubernetes one pod per node, one persistent volume per pod F 将 azure 磁盘安装到 azure Kubernetes 用于 Z399BD1EE587245ECAC6F39BEAA9pod988 - mount azure disk to azure Kubernetes for PostgreSQL pod Azure Kubernetes 永久卷 Azure 磁盘 - Azure Kubernetes Persistant Volume Azure Disk 在Azure中将外部磁盘连接到Kubernetes Pod - Attaching external disk on kubernetes pod in azure Azure kubernetes 更改 pod 磁盘类型 - Azure kubernetes change pod disk type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM