简体   繁体   English

拥有与节点一样多的 Pod

[英]Having as many Pods as Nodes

We are currently using 2 Nodes, but we may need more in the future.我们目前使用 2 个节点,但将来可能需要更多。

The StatefulSets is a mariadb-galera is current replica is at 2. StatefulSets 是一个mariadb-galera,当前副本位于 2。

When we'll had a new Nodes we want the replica to be a 3, f we don't need it anymore and we delete it or a other Node we want it to be a 2.当我们有一个新节点时,我们希望副本为 3,如果我们不再需要它,我们将其删除,或者我们希望它为 2 的其他节点。

In fact, if we have 3 Nodes we want 3 replica one on each Nodes.事实上,如果我们有 3 个节点,我们希望每个节点上有 3 个副本。

I could use Pod Topology Spread Constraints but we'll have a bunch of "notScheduled" pods.我可以使用Pod Topology Spread Constraints ,但我们会有一堆“notScheduled”pod。

Is there a way to adapt the number of Replica automatically, every time a nodes is add or remove?有没有办法在每次添加或删除节点时自动调整副本的数量?

When we'll had a new Nodes we want the replica to be a 3, f we don't need it anymore and we delete it or a other Node we want it to be a 2.当我们有一个新节点时,我们希望副本为 3,如果我们不再需要它,我们将其删除,或者我们希望它为 2 的其他节点。

I would recommend to do it the other way around.我建议反过来做。 Manage the replicas of your container workload and let the number of nodes be adjusted after that.管理容器工作负载的副本,然后调整节点数量。

See eg Cluster Autoscaler for how this can be done, it depends on what cloud provider or environment your cluster is using.请参阅Cluster Autoscaler了解如何完成此操作,这取决于您的集群使用的云提供商或环境。

It is also important to specify your CPU and Memory requests such that it occupy the whole nodes.指定您的CPU 和 Memory 请求也很重要,这样它就会占用整个节点。

For MariaDB and similar workload, you should use StatefulSet and not DaemonSet .对于 MariaDB 和类似的工作负载,您应该使用StatefulSet而不是DaemonSet

You could use a Daemon Set https://kube.netes.io/docs/concepts/workloads/controllers/daemonset/您可以使用守护进程集https://kube.netes.io/docs/concepts/workloads/controllers/daemonset/

Which will ensure there is one pod per node.这将确保每个节点有一个 pod。

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. DaemonSet 确保所有(或部分)节点运行 Pod 的副本。 As nodes are added to the cluster, Pods are added to them.当节点添加到集群中时,Pod 也会添加到它们中。 As nodes are removed from the cluster, those Pods are garbage collected.当节点从集群中移除时,这些 Pod 将被垃圾回收。 Deleting a DaemonSet will clean up the Pods it created.删除 DaemonSet 将清理它创建的 Pod。

Also, its not advised to run a database in anything else than a statefulset due to the pod identity concept as statefulsets have.此外,由于 statefulsets 具有 pod 身份概念,因此不建议在 statefulset 以外的任何地方运行数据库。

Due to all the database administration it is advisable to use any cloud provider managed databases or managing it, specially inside the cluster will incur in multiple issues由于所有的数据库管理,建议使用任何云提供商管理的数据库或对其进行管理,特别是在集群内部会导致多个问题

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

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