0

I have one k8s cluster with two nodes. One node lets say A, is a master+worker and the other B, is a worker only. Now, whenever a new deployment happens it goes to the worker node (B). I tried with multiple deployments and each of them got deployed on worker node (B) only.

I think its the behavior of scheduler to schedule deployments on worker node and keep master as low utilized as possible.

I want to distribute deployments in a round-robin manner so that if I have 6 deployments, each node would receive 3. I understand that I can do it by defining node constraints in the deployment file, but I wanted to know if there is any other way to achieve this?

Note- I tried a deployment with two replicas and both nodes received one pod. But the same is not the case with single replica. It always deployed on worker node (B) only.

Node A (master + worker) taint config

CreationTimestamp:  Thu, 18 Apr 2019 11:38:54 +0200
Taints:             <none>
Unschedulable:      false

Node B (worker only) taint config

CreationTimestamp:  Tue, 10 Dec 2019 08:37:25 +0100
Taints:             <none>
Unschedulable:      false
vivek
  • 187
  • 14
  • 1
    Does this answer your question? [Allow scheduling of pods on Kubernetes master?](https://stackoverflow.com/questions/43147941/allow-scheduling-of-pods-on-kubernetes-master) – Jonas Dec 14 '19 at 10:14

3 Answers3

0

You can run below command remove taint on master and all nodes

kubectl taint node --all node-role.kubernetes.io/master:NoSchedule-
Shambu
  • 2,612
  • 1
  • 21
  • 16
0

I want to distribute deployments in a round-robin manner so that if I have 6 deployments, each node would receive 3. I understand that I can do it by defining node constraints in the deployment file, but I wanted to know if there is any other way to achieve this?

First; you should not care about low-level details about scheduling. Let Kubernetes be responsible for that.

PodAffinity or PodAntiAffinity

The two things that you should care about regarding pod scheduling is wether a pod should be co-located with something else, or if a pod should avoid to be co-located with something. E.g. you may have want your application replicas to be scheduled on different nodes for fault tolerance / high availability.

See Pod Affinity and Pod Anti-Affinity

Jonas
  • 121,568
  • 97
  • 310
  • 388
0

The k8s component doing taking pods distribution decision is called "Scheduler", it takes its decision according to filtering and distribution policies

Filtering options

  • Node Taints as we have on master by default, the pod must tolerate node taints to bypass the limitation
kubectl get node -l kubernetes.io/role=master -o json | jq '.items[].spec.taints'
  {
    "effect": "NoSchedule",
    "key": "node-role.kubernetes.io/master"
  }
  • Resources requests, so Pod CPU and memory requests should be less than available resources on nodes.

  • NodeAffinities/AntiAffinities, Raise a condition of schedule depending on node labels

  • PodAffinities/AntiAffinities , Same like NodeAff* but depending on other pod labels

Notes.

  • All filters options has a soft and hard level of scheduling soft keywords "Preferred" hard keyworks "NoSchedule ,required "
  • you can create your custom Scheduler that can apply your own thoughts and priorities.
Tamer Elfeky
  • 100
  • 4