Skip to content

Instantly share code, notes, and snippets.

@zhangyuan
Created May 2, 2018 00:45
Show Gist options
  • Save zhangyuan/aa0c5f086299c39950891ca305848548 to your computer and use it in GitHub Desktop.
Save zhangyuan/aa0c5f086299c39950891ca305848548 to your computer and use it in GitHub Desktop.
const container = require('@google-cloud/container');
const clusterClient = new container.v1.ClusterManagerClient({
credentials: {
"private_key": "",
"client_email": "",
}
});
const projectId = 'projectId';
const zone = 'europe-west1-c';
const clusterName = 'clusterName';
async function createCluster() {
return await clusterClient.createCluster({
projectId: projectId,
zone: zone,
cluster: {
name: clusterName,
initialNodeCount: 1
}
});
}
async function deleteCluster() {
return await clusterClient.deleteCluster({
projectId: projectId,
zone: zone,
clusterId: clusterName
});
}
async function getCluster() {
const responses = await clusterClient.getCluster({
projectId: projectId,
zone: zone,
clusterId: clusterName,
})
return responses;
}
const main = async () => {
const createClusterRes = await createCluster();
console.log(createClusterRes);
const deleteClusterRes = await deleteCluster();
console.log(deleteClusterRes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment