如何跨多个节点分配相等的部署

How to assign equal deployments across multiple nodes

这看起来应该很简单,但我一直没能找到答案。

我们有三个标记节点:

thalia0 thalia1 thalia2

和名为 mm-sa 的部署规范。

我只想将 mm-sa 的副本数设置为 48,并让调度程序为每个节点分配 16 pods。

我能找到的最接近这个的是在这里,但它看起来还没有可用:Node affinity for even spread of pods across multiple availability zones. I also found this, ,但它说 "According to the documentation, nodeAffinity must exist for each node that can be used for a scheduled pod and the node having the biggest weight sum is chosen."

这似乎是一个如此简单的用例,但我无法弄清楚如何在不使用天真的方法的情况下实现它,例如定义名为 mm-sa1、... [=16 的 3 个不同的部署=] 并使用 nodeSelector 相应地分配每个。 (注意:我目前正在使用 nodeSelector 在单个节点上分配 mm-sa 的 16 个副本)。

Kubernetes 会自动将 pods 分布在复制控制器或跨节点服务的单区域集群中。所以如果没有其他节点,@David Maze 的解决方案应该适用。但是,由于您提到您不想安排其他节点,我建议使用 nodeSelector。通过使用 nodeSelector,只要节点在 YAML 中具有相同的键值对,pod 就可以在该节点上进行调度。

您可以在此处阅读有关 nodeSelector 的更多信息:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector