Deployment - node selector per replica

4/26/2017

How to express : "Yo kubernetes, run 3 replicas, but at-least 1 of them must be running on a node with label cost=expensive"

Lets say I have 2 sets of worker nodes(minions).

Set 1 with label cost=expensive. Set 2 cost=cheap.

I want to run a Deployment with 3 replica such that at-least one of them is scheduled on a Set 1, and I don't care where the other 2 replicas are launched.

notes:-

  1. I am running Kubernetes 1.6.2.
  2. Example use case: Set 2 consists of spot instances which can die at any-moment. I would like atleast 1 pod running on on-demand instance.
  3. I've read the Assigning Pods to Nodes guide which lets me (a) (podAntiAffinity) spread pods across nodes; or (b) (nodeSelector or nodeAffinity) put soft/hard constraints on what selectors all pods will run.
  4. I could run the pods on 2 separate deployments, one with 1 replica and nodeSelector set to cost=expensive, but that makes it messy.
-- sajal
kubernetes

1 Answer

5/3/2017

I think you should run 2 deployments, pods in same deployment or replica set means same configuration, spread them to different kinds of custom node set is not the case. If you want them provide service together, you can set correct labels and make them work behind same service.

BTW, you can do this job by customizing scheduler policy, while that is too expansive.

-- Crazykev
Source: StackOverflow