Avoid scheduling multiple pod instances on same physical host running VMs as nodes

7/17/2018

This is not a current practical issue, but a theoretical question. Assume K8S worker nodes N1,N2,N3..Nn are actually virtual machines on physical hosts H1,H2,H3 such that N1 and N2 are currently on H1. When I want to schedule 5 instances of my pod P1, is there any awareness in K8S about the underlying physical host H1? Or is it possible that all 5 instances could be scheduled on N1 and N2 - resulting in all 5(P1) been on H1?

-- aaaaarrrgghhh
kubernetes

1 Answer

7/17/2018

First of all, let's say "no". In case of "bare metal" (or VMs above bare metal) The Kubernetes "knows" only about his nodes (etcd, master, worker) and doesn't know anything about physical host, where VMs are located. But, you can label your nodes with some key/value pairs, which will ensure that this VM belongs to a physical host.

Secondly, let's say "yes". How any deployments of pods will be scheduled to nodes - is a k8s scheduler's task, which is a part of k8s master's control plane. Default scheduler has got an algorithm how to detect the most appropriate k8s node for deploying. So, theoretically H1 could host all 5 instances of you application.

Good news that it's really unlikely. Moreover, the Kubernetes provides you an ability to create your own custom scheduler with your own logic for scheduling and use it only for specific deployments. That's why it's hard to believe there will be case for scheduling you could not be able to resolve.

P.S: actually, k8s scheduling - is a too large subject to describe in a nutshell. Sufficient time should be allocated for the examination of your cases. Try to start from reading "kubernetes advance scheduling": https://kubernetes.io/blog/2017/03/advanced-scheduling-in-kubernetes/

Sure, it'll will help you to go forward. Good luck!

-- Konstantin Vustin
Source: StackOverflow