0

I want my GKE cluster nodes to decrease to zero during non-business hours and increase again during business hours to save on cloud costs. I've set up a cloud function to handle this, which works for stopping and starting nodes. However, when autoscaling is enabled on the cluster, it doesn't work as the autoscaler scales it back up even after it's been shut down.

Is there any way I can do this?

1
  • You can't ask for autoscalling and perform manual scaling of your cluster! Either you delegate this task or you handle it. In summary, it's normal it does not work. So, make a choice between the 2 options. A 3rd option, if your workload is compliant, is to use Cloud Run. It scale up and down automatically. And you pay only when a request is processed. Commented Jul 10 at 7:29

1 Answer 1

1

As guillaume blaquiere suggested, Cloud Run automatically scales up and down based on traffic, by eliminating the need for manual scaling and auto scaling conflicts.

You can use Cloud Scheduler to schedule a script to be executed on Cloud Run, for example, and have it scale up or down the node pool according to your start and end business hours.

Cloud Scheduler - Set up two cloud scheduler jobs. One to run during the end of business hours to scale down the nodes and disable auto scaling, another one to run at the start of business hours to scaleup and re-enable autoscaling.

Cloud Functions - Create two Cloud Functions corresponding to each job.

Creating pub/sub topics : That can be used in Cloud Function. Select the cloud Pub/Sub as a trigger, once the Cloud Function is triggered we can verify the node count of the GKE cluster is reduced.

Another way : Use kubernetes Cluster AutoScaler with enabling Node Auto-provisioning- It is dynamically created and deleted node pools based on resource requirement. This method provides a solution to scale up and scale down by reducing cost.

Beginning with Kubernetes version 1.7, you can specify a minimum size of zero for your node pool. This allows your node pool to scale down completely if the instances within aren't required to run your workloads.

And also refer to Rittik Gupta’s Medium blog for more details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.