首页 文章

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

提问于
浏览
1

我有一个沙盒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将所有这些 beans 荚安排在一起?

我们的想法是让集群在晚上与主服务器加一个节点运行 . 如果没有,我正在考虑将 Scheduled Action 添加到 AutoScale Group ,因此它将被强制在同一节点中运行 .

2 回答

  • 2

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

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

    从文档中,它将允许您指定以下规则:

    如果X已经运行了一个或多个符合规则Y的pod,则此pod应该(或者,如果是反关联,则不应该)在X中运行.X是拓扑域,如节点,机架, Cloud 提供程序区域, Cloud 提供商区域等

  • 1

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

相关问题