@arsh ,
That is correct! There is one more feature called "topology spread constraints" - that should also help out in evenly distributing your pods managed by deployment object on the nodes!
Take a look at the below article how to implement that:
Kubernetes official documentation about that feature:
https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
I just tested with below Sample YAML file:
with 3 replicas:
scaled to 6 replicas:(Distributed evenly on all the nodes)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: nginx
containers:
- name: nginx
image: nginx