2017-04-19 55 views
1

我有一個沙盒Kubernetes集羣,其中我在晚上關閉了所有豆莢,因此它可以通過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 

因爲這些豆莢蔓延,集羣自動配置器最終保持2個或多個節點工作,即使是沒有在運行默認名稱空間...

有沒有強制或誘導Kubernetes將所有這些豆莢一起排列的方法?

這個想法是讓集羣只在主節點和一個節點上運行。如果沒有,我想在AutoScale Group上增加一個Scheduled Action,所以它將被強制運行在同一個節點上。

回答

1

使用nodeselector的另一種方法是使用inter-pod affinity來確保您的pod打包得更好。

可以使用'首選'而不是'必需'關聯性來確保Kubernetes將嘗試在同一個節點上將您的pod安排在一起,但是如果不能,它們將安排在不同的節點上。

從文檔,它會讓你指定喜歡的規則:

該吊艙應該(或者,在 反關聯性的情況下,不應該)在X上運行,如果是X已經在運行 符合規則Y的一個或多個容器.X是類似節點,機架,雲提供商區域,雲提供商區域等拓撲結構域。

+0

這似乎是目前爲止最好的選擇。將研究這一點。謝謝! – caarlos0

2

解決方案可能是標記節點,然後使用部署中的nodeSelector指示必須在該節點上運行。這當然不是一個建議的解決方案,因爲一旦你擴展到很大程度,它就會崩潰。

相關問題