简体   繁体   English

Kube.netes topologySpreadConstraints 不会将 3 个 pod 均匀分布到 3 个区域(abc),而是将 1 放置到 a,将 2 放置到 b)

[英]Kubernetes topologySpreadConstraints doesn't distribute 3 pod evenly to 3 zone ( a b c), but places 1 to a, and 2 to b)

I'm trying to spread my pods to different availability zones.我正在尝试将 Pod 分布到不同的可用性区域。 I used topologySpreadConstraints feature with 3 replicas and such config:我将topologySpreadConstraints功能与 3 个副本和这样的配置一起使用:

  topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
          matchLabels:
              release: {{ .Release.Name }}

Worker nodes are available in 3 zones.工作节点在 3 个区域中可用。 The problem is when I deploy it, scheduler palces one pod to A-zone , and 2 pods in B-zone .问题是当我部署它时,调度程序将一个 pod 放置在A-zone中,将 2 个 pod 放置在B-zone中。 Instead of placing one into each zone.而不是在每个区域放置一个。 I understand that maxSkew: 1 , can't be set to 0 , and it allows scheduler to schedule unevenly with +1 skewness.我知道maxSkew: 1不能设置为0 ,它允许调度程序以 +1 偏度不均匀地调度。 But shouldn't the scheduler respect domain first?但是调度程序不应该首先尊重域吗? Like shouldn't it do best effort to spread 3 pods by different zones (domains) first?就像它不应该尽最大努力首先通过不同的区域(域)传播 3 个 pod 吗? Can it be done with help of topologySpreadConstraints ?可以在topologySpreadConstraints的帮助下完成吗? Or I should use podAntiAffinity ?或者我应该使用podAntiAffinity

Like you mentioned, maxSkew can't be set to 0. My guess is that it's done to handle odd number of pods.就像你提到的, maxSkew不能设置为 0。我的猜测是它已经完成处理奇数个 pod。 In your case: one pod in A and two pods in B still respects the maxSkew of one so the scheduler is doing its job properly.在您的情况下: A中的一个 pod 和B中的两个 pod 仍然遵守其中一个的maxSkew ,因此调度程序可以正常工作。 If you know for a fact that your replica count will always be 3 (maybe on a statefulset), you can use a podAntiAffinity rule instead of your topologySpreadContraints but this will not work with more than one pod per zone.如果您知道您的副本数将始终为 3(可能在有状态集上),则可以使用 podAntiAffinity 规则代替topologySpreadContraints但这不适用于每个区域超过一个 pod。 If you use a deployment, the simplest solution would be to increase the replica count.如果您使用部署,最简单的解决方案是增加副本数。 Something like 5 would do the trick.像 5 这样的东西就可以了。

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

相关问题 Kube.netes 不会将 Pod 调度到工作负载较小的节点 - Kubernetes doesn't schedule pod to the node with less workload 将 kube.netes pod 暴露给 inte.net - expose kubernetes pod to internet GCP VM 部署问题 - 区域“projects/xxxxx/zones/europe-west2-b”没有足够的可用资源来满足请求 - GCP VM deployment issues - The zone 'projects/xxxxx/zones/europe-west2-b' does not have enough resources available to fulfill the request 从 kubernetes 中的 pod 内部启动 pod - start a pod from inside a pod in kubernetes 如何从我的 pod 上的其他 kubernetes pod 渲染网站? - How to render website from other kubernetes pod on my pod? Kube.netes HPA 无法扩展 - Kubernetes HPA doesn't scale up Kube.netes autoscaler - NotTriggerScaleUp' pod 没有触发扩展(如果添加新节点则不适合) - Kubernetes autoscaler - NotTriggerScaleUp' pod didn't trigger scale-up (it wouldn't fit if a new node is added) Kube.netes Pod 无法将卷挂载到 GCP 文件存储 - Kubernetes Pod is unable to mount volumes to GCP Filestore 如何将节点选择器添加到 kube.netes 中的系统 pod? - How to add a node selector to a system pod in kubernetes? Kube.netes pod 错误:创建多个服务 - Kubernetes pod error: creating multiple services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM