Can kubernetes schedule multiple unrelated pods on one host?

11/14/2016

If I have 10 different services, each of which are independent from each other and run from their own container, can I get kubernetes to run all of those services on, say, 1 host?

This is unclear in the kubernetes documentation. It states that you can force it to schedule containers from the same pod onto one host, using a "multi-container pod", but it doesn't seem to approach the subject of whether you can have multiple pods running on one host.

-- Rob Gilton
kubernetes

2 Answers

11/14/2016

You can use node selectors and assign the same node for each of the pod to the same node / host

http://kubernetes.io/docs/user-guide/node-selection/

Having said that, the whole point to Kubernetes is to manage a cluster where you can deploy apps / pods across them.

-- manojlds
Source: StackOverflow

11/14/2016

In fact kubernetes will do exactly what you want by default. It is capable of running dozens if not hundreds of containers on a single host (depending on its specs).

If you want very advanced control over scheduling pods, there is an alpha feature for that, which introduces concept of node/pod (anti)affinities. But I would say it is a rather advanced k8s topic at the moment, so you are probably good with what is in stable/beta for most use cases.

Honorable mention: there is a nasty trick that allows you to control when pods can not be collocated on the same node. An that is when they both declare same hostPort in their ports section. It can be usefull for some cases, but be aware it affects ie. how rolling deployments happen in some situations.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow