Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow only one pod of a type on a node in Kubernetes

How to allow only one pod of a type on a node in Kubernetes. Daemon-sets doesn't fit into this use-case.

For e.g. - Restricting scheduling of only one Elasticsearch pod on a node, to prevent data loss in case the node goes down.

It can be achieved by carefully planning CPU/memory resource of pod and machine type of cluster.

Is there any other way to do so?

like image 620
Sunil Kumar Avatar asked Jan 08 '16 03:01

Sunil Kumar


1 Answers

Kubernetes 1.4 introduced Inter-pod affinity and anti-affinity. From the documentation: Inter-pod affinity and anti-affinity allow you to constrain which nodes your pod is eligible to schedule on based on labels on pods that are already running on the node.

That won't prevent a pod to be scheduled on a node, but at least the pod will be scheduled on the node if and only if the scheduler has no choice.

like image 116
Bastien Libersa Avatar answered Oct 21 '22 20:10

Bastien Libersa