In GCP, how to change default pool name while creating through gcloud cli?

To rename the default node pool at the creation of a GKE cluster is not possible neither when you have the cluster created. With gcloud container node-pools update you can modify the following parameters:

gcloud container node-pools update NAME (--node-locations=ZONE,[ZONE,…] | --system-config-from-file=SYSTEM_CONFIG_FROM_FILE | --workload-metadata=WORKLOAD_METADATA | --enable-autoprovisioning --enable-autoscaling --max-nodes=MAX_NODES --min-nodes=MIN_NODES | --enable-autorepair --enable-autoupgrade | --max-surge-upgrade=MAX_SURGE_UPGRADE --max-unavailable-upgrade=MAX_UNAVAILABLE_UPGRADE) [--cluster=CLUSTER] [--region=REGION | --zone=ZONE, -z ZONE] [GCLOUD_WIDE_FLAG …]

But not the name.

The workaround is:

  1. Create a new nodepool with the desired name. This is just an example I got from this document it is to change the machine type but it also works to create a new nodepool with another name.
gcloud container node-pools create new-node-pool \
  --cluster=mycluster\
  --machine-type=e2-highmem-2 \
  --num-nodes=5

Migrate the workloads :

  • Cordon the existing node pool.
  • Drain the existing node pool.

and then Delete the old nodepool.