[英]How can you scale Wordpress in Kubernetes cluster - using multiple pod replicas, - accessing a single PVC (persistent file storage)
I'm learning Kubernetes, and trying to setup a cluster that could handle a single Wordpress site with high traffic.我正在学习 Kubernetes,并尝试设置一个可以处理单个高流量 Wordpress 站点的集群。 From reading multiple examples online from both Google Cloud and Kubernetes.io - they all set the "accessMode" - "readWriteOnce" when creating the PVCs.
从 Google Cloud 和 Kubernetes.io 在线阅读多个示例 - 它们在创建 PVC 时都设置了“accessMode”-“readWriteOnce”。
Does this mean if I scaled the Wordpress Deployment to use multiple replicas, they all use the same single PVC to store persistent data - read/write data.这是否意味着如果我扩展 Wordpress 部署以使用多个副本,它们都使用相同的单个 PVC 来存储持久数据 - 读/写数据。 (Just like they use the single DB instance?)
(就像他们使用单个数据库实例一样?)
The google example here only uses a single-replica, single-db instance - https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk此处的 google 示例仅使用单副本、单数据库实例 - https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk
My question is how do you handle persistent storage on a multiple-replica instance?我的问题是如何处理多副本实例上的持久存储?
ReadWriteOnce means all replicas will use the same volume and therefore they will all run on one node. ReadWriteOnce 意味着所有副本将使用相同的卷,因此它们都将在一个节点上运行。 This can be suboptimal.
这可能是次优的。
You can set up ReadWriteMany volume (NFS, GlusterFS, CephFS and others) storage class that will allow multiple nodes to mount one volume.您可以设置 ReadWriteMany 卷(NFS、GlusterFS、CephFS 等)存储类,允许多个节点挂载一个卷。
Alternatively you can run your application as StatefulSet with volumeClaimTemplate which ensures that each replica will mount its own ReadWriteOnce volume.或者,您可以将应用程序作为 StatefulSet 与 volumeClaimTemplate 一起运行,以确保每个副本都将挂载自己的 ReadWriteOnce 卷。
If on AWS (and therefore blocked by the limitation of EBS volumes only mountable on a single instance at a time), another option here is setting up the Pod Affinity to schedule on the same node.如果在 AWS 上(因此被 EBS 卷一次只能安装在一个实例上的限制所阻止),这里的另一个选项是设置 Pod Affinity 以在同一节点上进行调度。 Not ideal from an HA standpoint, but it is an option.
从 HA 的角度来看并不理想,但它是一种选择。
If after setting that up you start running into any wonky issues (eg unable to login to the admin, redirect loops, disappearing media), I wrote a guide on some of the more common issues people run into when running Wordpress on Kubernetes, might be worth having a look!若设置为高达你开始运行到任何靠不住的问题(例如无法登录到管理,重定向循环,消失的媒体)之后,我写了一个引导上的一些人运行更常见的问题上Kubernetes运行WordPress的时候进入,可能是值得一看!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.