How to deploy deployments in multiple nodes in kubernetes?

2k Views Asked by At

i have a bare-metal kubernetes cluster with 1 master node and 4 worker nodes. I want to deploy my deployment objects on every 4 worker nodes but i can't. I try nodeSelector but looks like it only works on last key:value pair label.

Please help me.

1

There are 1 best solutions below

0
On

If you want to ensure that all nodes have that pod on them you can use a DaemonSet.

You can also use affinity/anti-affinity selectors.

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”

If you don't want to two instances are located on the same host, check following link

https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#never-co-located-in-the-same-node