强制某些pod在同一节点上进行调度

时间:2017-04-19 16:42:11

标签: kubernetes

我有一个沙箱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是分散的,因此即使默认命名空间中没有任何内容运行,cluster-autoscaler最终也会保留2个或更多节点...

有没有办法强制或诱使Kubernetes将所有这些豆荚安排在一起?

这个想法是让集群在晚上与主节点和一个节点一起运行。如果没有,我正在考虑向Scheduled Action添加AutoScale Group,因此它将被强制在同一节点中运行。

2 个答案:

答案 0 :(得分:2)

解决方案可能是标记节点,然后使用部署中的nodeSelector指示必须在该节点上运行。这肯定不是一个建议的解决方案,因为一旦你扩展到很多就会中断。

答案 1 :(得分:1)

使用nodeselector的另一种方法是使用inter-pod affinity来确保您的pod更好地打包。

'首选'而不是'必需'亲和关系可用于确保Kubernetes将尝试在同一节点上将您的pod安排在一起,但如果不能,则会在不同节点上安排。

从文档中,它可以让您指定以下规则:

  

这个吊舱应该(或者,在...的情况下)   如果X已经在运行,则反关联,不应该在X中运行   一个或多个符合规则Y的pod.X是拓扑域,如节点,机架,云提供商区域,云提供商区域等。

相关问题