GKE: migrating existing cluster to larger machine


Prerequisite: what machine type do you want?

To list the available machine types:

gcloud compute machine-types list

Create a new node pool of machines in the cluster

gcloud container node-pools create larger-pool --cluster=cluster-1 \
      --machine-type=n1-highcpu-8 --num-nodes=3

To list the available node-pools in the cluster:

gcloud container node-pools list --cluster cluster-1

POD migration

To view which nodes the PODs are running:

kubectl get pods -o=wide

Next, is two step process:

1. Cordon

for node in $(kubectl get nodes -l cloud.google.com/gke-nodepool=default-pool -o=name); do
  kubectl cordon "$node";
done

Verify if scheduling is disabled:

kubectl get nodes

2. Drain PODs gracefully

for node in $(kubectl get nodes -l cloud.google.com/gke-nodepool=default-pool -o=name); do
  kubectl drain --force --ignore-daemonsets --delete-local-data --grace-period=10 "$node";
done

Verify if migration is in progress or finished:

kubectl get pods -o=wide

Delete old node pool

gcloud container node-pools delete default-pool --cluster cluster-1

Source: https://cloud.google.com/kubernetes-engine/docs/tutorials/migrating-node-pool

Posted on Tue Sep 18 13:37:00 EDT 2018 by Subhash Chandran
gke kubernetes gcp k8s