How to retrieve node-pool size from a k8s cluster?

1/24/2019

I couldn't find useful information from:

gcloud container clusters describe CLUSTER_NAME

or from

gcloud container node-pools describe POOL_NAME --cluster CLUSTER_NAME

It is easy to scale up/down using gcloud tool though:

gcloud container clusters resize [CLUSTER_NAME] --node-pool [POOL_NAME] \
    --size [SIZE]

But how can I know beforehand what is the size of my node-pool?

-- Montenegrodr
gcloud
kubernetes

2 Answers

4/8/2019

I do not agree with the current answer because it only gives the total size of the cluster.

The question is about node-pools. I actually needed to find out the size of a pool so I give you my best shot after many hours of searching and thinking.

read -p 'Cluster name: ' CLUSTER_NAME
read -p 'Pool name:    ' POOL_NAME

gcloud compute instance-groups list \
 | grep "^gke-$CLUSTER_NAME-$POOL_NAME" \
 | awk '{print $6}';

The gcloud command returns 6 columns: 1-name, 6-group-size. The name of the instance group is predictable which lets me filter by that line with grep. Lastly, select the 6th column.

Hope this helps someone else save some time.


For some reason I overlooked the not-so-obviuos from Migrating workloads to different machine types

kubectl get nodes -l cloud.google.com/gke-nodepool=$POOL_NAME -o=name \
  | wc -l
-- hanzo2001
Source: StackOverflow

1/25/2019

You should use the following command:

gcloud container clusters describe <cluster name> --zone <zone-cluster>

Check for the field currentNodeCount

-- Luke
Source: StackOverflow