简体   繁体   English

Kubernetes - 扩展部署 Pod 时未安装卷

[英]Kubernetes - Volume not getting mounted when I scale the deployment pods

I have got a deployment.yaml and it uses a persistentvolumeclaim like so我有一个 deployment.yaml,它使用了一个持久卷声明

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mautic-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: standard

I am trying to scale my deployment horizontally using (Horizontal Pod Scheduler) but when I scale my deployment, the rest of the pods are in ContainerCreating process and this is the error I get when I describe the pod我正在尝试使用 (Horizo​​ntal Pod Scheduler) 水平扩展我的部署,但是当我扩展我的部署时,其余的 pod 都在ContainerCreating过程中,这是我在describe the pod时遇到的错误

Unable to attach or mount volumes: unmounted volume

What am I doing wrong here?我在这里做错了什么?

Using Deployment is great if your app can scale horizontally .如果您的应用程序可以水平扩展,那么使用Deployment会很棒。 However, using aPersistent Volume with a PersistentVolumeClaim can be challenging when scaling horizontally .但是,在水平扩展时,将Persistent VolumePersistentVolumeClaim可能具有挑战性。

Persistent Volume Claim - Access Modes持久卷声明 - 访问模式

A PersistentVolumeClaim can be requested for a few different Access Modes :可以为几种不同的访问模式请求PersistentVolumeClaim

  • ReadWriteOnce (most common) ReadWriteOnce(最常见)
  • ReadOnlyMany只读多
  • ReadWriteMany读写多

Where ReadWriteOnce is the most commonly available and is typical behavior for a local disk.其中ReadWriteOnce是最常用的,并且是本地磁盘的典型行为。 But to scale your app horizontally - you need a volume that is available from multiple nodes at the same time, so only ReadOnlyMany and ReadWriteMany is viable options.但是要水平扩展您的应用程序 - 您需要一个可同时从多个节点使用的卷,因此只有ReadOnlyManyReadWriteMany是可行的选项。 You need to check what what access modes are available for your storage system .您需要检查哪些访问模式可用于您的存储系统

In addition, you use a regional cluster from a cloud provider, it spans over three Availability Zones and a volume typically only live in one Availability Zone , so even if you use ReadOnlyMany or ReadWriteMany access modes, it makes your volume available on multiple nodes in the same AZ, but not available in all three AZs in your cluster.此外,您使用来自云提供商的区域集群,它跨越三个可用区,并且一个卷通常只存在于一个可用区中,因此即使您使用ReadOnlyManyReadWriteMany访问模式,它也会使您的卷在多个节点上可用相同的可用区,但并非在集群中的所有三个可用区中都可用。 You might consider using a storage class from your cloud provider that is replicated to multiple Availability Zones , but it typically costs more and is slower.您可能会考虑使用来自您的云提供商的存储类该类被复制到多个可用,但它通常成本更高且速度更慢。

Alternatives备择方案

Since only ReadWriteOnce is commonly available, you might look for better alternatives for your app.由于通常只有ReadWriteOnce可用,您可能会为您的应用程序寻找更好的替代方案。

Object Storage对象存储

Object Storage, or Buckets, is a common way to handle file storage in the cloud instead of using filesystem volumes.对象存储或存储桶是在云中处理文件存储而不是使用文件系统卷的常用方法。 With Object Storage you access you files via an API over HTTP.使用对象存储,您可以通过 HTTP 上的 API 访问您的文件。 See eg AWS S3 or Google Cloud Storage .参见例如AWS S3Google Cloud Storage

StatefulSet状态集

You could also consider StatefulSet where each instance of your app get its own volume.您还可以考虑StatefulSet ,其中应用程序的每个实例都有自己的卷。 This makes your app distributed but typically not horizontally scalable .这使您的应用程序分布但通常不能水平扩展 Here, your app typically needs to implement replication of data, typically using Raft and is a more advanced alterantive.在这里,您的应用程序通常需要实现数据复制,通常使用Raft并且是更高级的替代方案。

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

相关问题 如何将使用持久卷声明的 Kubernetes 部署扩展到 2 个 Pod? - How to scale a Kubernetes deployment which uses a Persistent Volume Claim to 2 Pods? 如何根据Pod的“就绪” /“未就绪”状态使Kubernetes扩展部署? - How do I make Kubernetes scale my deployment based on the “ready”/ “not ready” status of my Pods? 在 Kubernetes 中,如何在空闲时将部署扩展到零 - In Kubernetes, how can I scale a Deployment to zero when idle 在Kubernetes POD中安装了副本3仲裁器1的GlusterFS卷包含零大小的文件 - GlusterFS volume with replica 3 arbiter 1 mounted in Kubernetes PODs contains zero size files 缩小 Kubernetes pod - Scale down Kubernetes pods Kubernetes 不会将数据复制到已安装的卷中 - Kubernetes not copying data into mounted Volume Kubernetes; 如何将卷挂载到容器 - Kubernetes; How a volume is mounted to a container 如何在Kubernetes中创建一个在Pod死后不会被破坏的卷? - How to create a volume in kubernetes that is not destroyed when the pods die? 同时自动缩放音量和Pod(Kubernetes) - Autoscale volume and pods simultaneously (Kubernetes) 扩展 AWS 后,Kube.netes pod 卡住了。 卷的多重附加错误 - Kubernetes pods are stuck after scale up AWS. Multi-Attach error for volume
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM