gpt4 book ai didi

kubernetes - 强制某些 Pod 调度在同一节点上

转载 作者:行者123 更新时间:2023-12-02 11:58:51 31 4
gpt4 key购买 nike

我有一个沙箱 Kubernetes 集群,我在晚上关闭了其中的所有 Pod,以便可以使用 cluster-autoscaler 插件缩小规模。

问题是,它几乎总是保持主节点加 2 个节点运行。

查看cluster-autoscaler日志,我发现问题似乎是这样的:

Fast evaluation: node ip-172-16-38-51.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: dns-controller-3586597043-531v5
Fast evaluation: node ip-172-16-49-207.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: heapster-564189836-3h2ts
Fast evaluation: node ip-172-16-49-207.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: kube-dns-1321724180-c0rjr
Fast evaluation: node ip-172-16-49-207.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: kube-dns-autoscaler-265231812-dv17j
Fast evaluation: node ip-172-16-49-207.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: kubernetes-dashboard-2396447444-6bwtq
Fast evaluation: node ip-172-16-49-207.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: monitoring-influxdb-grafana-v4-50v9d
Fast evaluation: node ip-172-16-51-146.ec2.internal cannot be removed: non-deamons set, non-mirrored, kube-system pod present: cluster-autoscaler-776613730-kqgk2

并且由于这些 Pod 是分散的,即使默认命名空间中没有任何内容运行,集群自动缩放器最终也会保持 2 个或更多节点的运行......

有没有办法强制或诱导 Kubernetes 将所有这些 Pod 一起调度?

这个想法是让集群在夜间运行,仅使用主节点加一个节点。如果没有,我正在考虑向 AutoScale Group 添加一个 Scheduled Action,这样它将被迫在同一节点中运行。

最佳答案

使用节点选择器的替代方法是使用 inter-pod affinity确保您的 pod 包装得更好。

“首选”关联性而非“必需”关联性可用于确保 Kubernetes 会尝试将您的 Pod 一起调度到同一节点上,但如果不能,它们将调度到不同的节点上。

根据文档,您可以指定如下规则:

This pod should (or, in the case of anti-affinity, should not) run in an X if that X is already running one or more pods that meet rule Y. X is a topology domain like node, rack, cloud provider zone, cloud provider region, etc.

关于kubernetes - 强制某些 Pod 调度在同一节点上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43501508/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com