Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move pods to a new node pool/ instance group

I have a Gke cluster with one node pool attached

I want to make some changes to the node pool though- like adding tags, etc

So I created a new node pool with my new config and attached to the cluster. so now cluster has 2 node pools.

At this point I want to move the pods to the new node pool and destroy the old one

How is this process done? Am I doing this right?

like image 582
red888 Avatar asked Jun 15 '19 14:06

red888


People also ask

How do I move pods from one node to another?

First of all you cannot “move” a pod from one node to another. You can only delete it from one node and have it re-created on another. To delete use the kubectl delete command. To ensure a pod lands on a specific node using node affinity/taints and tolerations.

Can we run containers of same pod on different nodes?

In a pre-container world, they would have run on the same physical or virtual machine. Pods are tied to the Node where they are deployed and remain there until termination (according to restart policy) or deletion. In case of a Node failure, new identical Pods will be deployed on other available Nodes.

Does Kubernetes spread pods across nodes?

Node behaviorKubernetes automatically spreads the Pods for workload resources (such as Deployment or StatefulSet) across different nodes in a cluster. This spreading helps reduce the impact of failures.

What happens when you cordon a node?

Cordon will mark the node as unschedulable. Uncordon will mark the node as schedulable. The given node will be marked unschedulable to prevent new pods from arriving. Then drain deletes all pods except mirror pods (which cannot be deleted through the API server).


1 Answers

There are multiple ways to move your pods to the new node pool.

One way is to steer your pods to the new node pool using a label selector in your pod spec, as described in the "More fun with node pools" in the Google blog post that announced node pools (with the caveat that you need to forcibly terminate the existing pods for them to be rescheduled). This leaves all nodes in your cluster functional, and you can easily shift the pods back and forth between pools using the labels on the node pools (GKE automatically adds the node pool name as a label to make this easier).

Another way is to follow the tutorial for Migrating workloads to different machine types, which describes how to cordon / drain nodes to shift workloads to the new node pool.

Finally, you can just use GKE to delete your old node pool. GKE will automatically drain nodes prior to deleting them, which will cause your workload to shift to the new pool without you needing to run any extra commands yourself.

like image 74
Robert Bailey Avatar answered Sep 24 '22 02:09

Robert Bailey