Created
October 29, 2022 07:31
-
-
Save harsh4870/74df90e58e7dc6fcc6a5951562c5ffb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* PubSub function get data from PubSub and resize the GKE cluster pools based on data */ | |
const Buffer = require("safe-buffer").Buffer; | |
const container = require("@google-cloud/container"); | |
const client = new container.v1.ClusterManagerClient(); | |
exports.helloPubSub = async (message, context) => { | |
const payload = JSON.parse(Buffer.from(message.data, "base64").toString()); | |
const request = { | |
projectId: payload.projectId, | |
zone: payload.zone, | |
clusterId: payload.cluster_id, | |
nodePoolId: payload.node_pool_id, | |
nodeCount: payload.node_count, | |
}; | |
const result = await client.setNodePoolSize(request); | |
const operation = result[0]; | |
console.log(operation); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment