[英]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
我正在尝试使用 (Horizontal 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 Volume与PersistentVolumeClaim
可能具有挑战性。
A PersistentVolumeClaim
can be requested for a few different Access Modes :可以为几种不同的访问模式请求PersistentVolumeClaim
:
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.但是要水平扩展您的应用程序 - 您需要一个可同时从多个节点使用的卷,因此只有ReadOnlyMany
和ReadWriteMany
是可行的选项。 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.此外,您使用来自云提供商的区域集群,它跨越三个可用区,并且一个卷通常只存在于一个可用区中,因此即使您使用ReadOnlyMany
或ReadWriteMany
访问模式,它也会使您的卷在多个节点上可用相同的可用区,但并非在集群中的所有三个可用区中都可用。 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.您可能会考虑使用来自您的云提供商的存储类,该类被复制到多个可用区,但它通常成本更高且速度更慢。
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 S3或Google 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.