How to ensure every kubernetes node running 2 or more pods?

5/17/2020

I know that DaemonSets ensure only one pod running in every node. I know that ReplicaSets ensure the number of pod replicas defined are running but doesn't ensure every node gets a pod.

My requirement is every Node should be occupied by one POD and also I should be able to increase pod replica count! Is there any way we can achieve this?

If we can deploy application 2 times with different names i.e 1st time with Daemonsets and next with Replicasets! But is there any better approach? So that deployment can have a single manifest file with single name.

FYI, his am trying to achieve in Google Cloud- GKE.

-- sudhir tataraju
google-kubernetes-engine
kubernetes
kubernetes-helm
kubernetes-pod
kubernetes-statefulset

1 Answer

5/17/2020

First of all, a daemonset can also be configured and restricted not to spawn pods on all the nodes.

Yes, you can achieve a pod to spawn on every node by a deployment object by pod affinity with topologykey set as "kubernetes.io/hostname".

With the above example, you will have the following behaviour:

topology key

I hope thats what you are looking for: enter image description here

-- redzack
Source: StackOverflow