How to convert Daemonsets to kind Deployment

8/2/2018

I have already deployed pods using Daemonsets with nodeselector. My requirements is I need to use kind Deployment but at the same time I would want to retain Daemonsets functionality .I have nodeselector defined so that same pod should be installed in labelled node. How to achieve your help is appreciated. My requirements is pod should be placed automatically based on nodeselector but with kind Deployment In otherwords Using Replication controller when I schedule 2 (two) replicas of a pod I expect 1 (one) replica each in each Nodes (VMs). Instead I find both replicas are created in same node This will make 1 Node a single point of failure which I need to avoid.

I have labelled two nodes properly. And I could see both pods spawned on single node. How to achieve both pods always schedule on both nodes?

-- Selvakumar Shunmugam
kubectl
kubernetes
kubernetes-helm

1 Answer

8/2/2018

Look into affinity and anti-affinity, specifically, inter-pod affinity and anti-affinity.

From official documentation:

Inter-pod affinity and anti-affinity allow you to constrain which nodes your pod is eligible to be scheduled based on labels on pods that are already running on the node rather than based on labels on nodes. The rules are of the form “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”.

-- mythic
Source: StackOverflow