I am using Google Kubernetes Engine. I have a multiple Kubernetes cluster node-pools. I want to delete one of them.

Is there a way that I can first migrate all the pods on one node-pool to another node-pool through the same kind of rolling update methods found in other features?

I thought it would do this automatically for me. But when I deleted the node-pool I got downtime, luckily this was not a production environment.

I would like to know if there is a way to automatically migrate and move all pods from one node-pool to another node-pool and slowly roll the change when a node-pool is removed?

Thanks

If you cordon and drain the nodepool before deleting it, then you can avoid downtime. I use the following script (shamelessly taken from the lazyweb elsewhere and adapted to my needs):

oldpool=pool-1
oldnodes=$(k get no --selector='cloud.google.com/gke-nodepool='$oldpool -o json | jq .items[].metadata.name -r | xargs)

kubectl cordon --selector='cloud.google.com/gke-nodepool='$oldpool

for n in $oldnodes; do
  echo "draining $n"
  kubectl drain --delete-local-data --ignore-daemonsets $n
  echo "----------------------------"
done;
  • On aws using kops everything this automatically – c4f4t0r 2 days ago

1). Inside the node pool(lets call it old_node_pool ) that you want to delete, First Cordon all the nodes one after the other.

 kubectl cordon <name_of_node_1>
 kubectl cordon <name_of_node_2>
           ........ 

2). Drain all the nodes of the old_node_pool.

 kubectl drain <name_of_node_1>
 kubectl drain <name_of_node_2>
           ........ 

3). Wait to see all the pods are up and running on the new node pool.

4). Delete the old node pool.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.