How to require one pod per minion/kublet when configuring a replication controller?

吃可爱长大的小学妹 提交于 2019-11-30 18:52:26

问题


I have 4 nodes (kubelets) configured with a label role=nginx

master ~ # kubectl get node
NAME          LABELS                                          STATUS
10.1.141.34   kubernetes.io/hostname=10.1.141.34,role=nginx   Ready
10.1.141.40   kubernetes.io/hostname=10.1.141.40,role=nginx   Ready
10.1.141.42   kubernetes.io/hostname=10.1.141.42,role=nginx   Ready
10.1.141.43   kubernetes.io/hostname=10.1.141.43,role=nginx   Ready

I modified the replication controller and added these lines

spec:
  replicas: 4
  selector:
    role: nginx

But when I fire it up I get 2 pods on one host. What I want is 1 pod on each host. What am I missing?


回答1:


Prior to DaemonSet being available, you can also specify that you pod uses a host port and set the number of replicas in your replication controller to something greater than your number of nodes. The host port constraint will allow only one pod per host.




回答2:


I was able to achieve this by modifying the labels as follows below

master ~ # kubectl get nodes -o wide
NAME          LABELS                                           STATUS
10.1.141.34   kubernetes.io/hostname=10.1.141.34,role=nginx1   Ready
10.1.141.40   kubernetes.io/hostname=10.1.141.40,role=nginx2   Ready
10.1.141.42   kubernetes.io/hostname=10.1.141.42,role=nginx3   Ready
10.1.141.43   kubernetes.io/hostname=10.1.141.43,role=nginx4   Ready

I then created 4 nginx replication controllers each referencing the nginx{1|2|3|4} roles and labels.




回答3:


Replication controller doesn't guarantee one pod per node as the scheduler will find the best fit for each pod. I think what you want is the DaemonSet controller, which is still under development. Your workaround posted above would work too.



来源:https://stackoverflow.com/questions/33377054/how-to-require-one-pod-per-minion-kublet-when-configuring-a-replication-controll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!