[英]How to guarantee even spread pod distribution across AZ in Kubernetes StatefulSet
I deployed a K8s StatefulSet with 30 replicas (or N replicas, where N is multiple of 3) in EKS Cluster.我在 EKS 集群中部署了一个具有 30 个副本(或 N 个副本,其中 N 是 3 的倍数)的 K8s StatefulSet 。
EKS cluster is with 3 nodes, one node for one AZ, and I want to guarantee with Kubernetes Affinity/AntiAffinity the equal distribution of pods across different AZ. EKS 集群有 3 个节点,一个节点用于一个 AZ,我想通过 Kubernetes Affinity/AntiAffinity保证Pod 在不同 AZ 之间的平均分布。
us-west-2a (n nodes) -> N/3 pods
us-west-2b (m nodes) -> N/3 pods
us-west-2c (o nodes) -> N/3 pods
Thanks谢谢
While this is too possible with node affinity, a straight forward way is the use of topologySpreadContraints, here's the k8s documentation, diagrams and examples to see it in action.虽然这对于节点亲和力来说太可能了,但直接的方法是使用 topologySpreadContraints,这里是 k8s 文档、图表和示例以查看它的实际应用。
You can always use selectors and default labels which you get from AWS.您始终可以使用从 AWS 获得的选择器和默认标签。 A simple pod spec example is here
一个简单的 pod 规范示例在这里
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: myapp
You can include skew and other options based on the need as described here: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/您可以根据此处所述的需要包括偏斜和其他选项: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.