how to run gcloud container command using api

5/11/2020

I am using this gcloud command to resize my GKE cluster

   gcloud container clusters resize $CLUSTER_NAME --num-nodes=0

how can I achieve the same using the api?

I found @google-cloud/container library, what function should I be using?

-- dina
gcloud
google-kubernetes-engine

1 Answer

5/11/2020
const container = require('@google-cloud/container');
const client = new container.v1.ClusterManagerClient();

const request = {
    projectId: 'my-project-id',
    zone: 'us-central1-f',
    clusterId: 'my-cluster-id',
    nodePoolId: 'default-pool',
    nodeCount: 0
};

client.setNodePoolSize(request, (err, res) => {
    console.log(err);
    console.log(res);
});

see also api reference

-- dina
Source: StackOverflow