Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run two pods in exclusive nodes?

Tags:

kubernetes

I'd like to run two pods in exclusive nodes. For instance, I have 4 nodes (node-1, node-2, node-3, node-4) and 2 pods (pod-1, pod-2). I want only one pod to run in each node and each pod to run in two nodes, e.g. pod-1 in node-1 and node-2, pod-2 in node-3 and node-4. Is there a way to configure this way?

like image 866
yanana Avatar asked Jun 22 '15 09:06

yanana


People also ask

Can a node run multiple pods?

A Node can have multiple pods, and the Kubernetes control plane automatically handles scheduling the pods across the Nodes in the cluster.

How many pods can run on a node?

Overview. By default, GKE allows up to 110 Pods per node on Standard clusters, however Standard clusters can be configured to allow up to 256 Pods per node. Autopilot clusters have a maximum of 32 Pods per node.

How do I run a pod on a specific node?

You can add the nodeSelector field to your Pod specification and specify the node labels you want the target node to have. Kubernetes only schedules the Pod onto nodes that have each of the labels you specify. See Assign Pods to Nodes for more information.


1 Answers

You can force exclusivity by creating pod definitions that are unable to schedule on the same machine. The easiest way to do that is to assign each pod the same host port. Once you have the same host port set for both of your pod definitions, if you create two replication controllers with two replicas each, then the scheduler will run 2 copies of 2 pods spread across 4 machines.

like image 90
Robert Bailey Avatar answered Sep 17 '22 04:09

Robert Bailey