Autoscale GKE nodes to 0 when no new requests received from user for some time

11/2/2019

I am building an app that has some microservices deployments on a GKE cluster with a n1-standard-2 node.

Since it is a small app with sporadic and little traffic, there maybe instances when my app does not receive traffic for some time.

To reduce costs.

  • Can I autoscale-down all my nodes running the server pods to zero, when no user request for some time. When a new request comes, autoscale-up to handle the request.

If this is possible, how can I do this in GKE?

If this is not feasible, what other options can I use to reduce costs?

-- Harsh Agarwal
autoscaling
google-cloud-platform
google-kubernetes-engine
kubernetes

2 Answers

11/4/2019

norbjd had already mentioned to you that it is possible configure a cluster autoscaler and specify a minimum of 0 nodes for your node pool if you wish to do so.

Understand that 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. (i.e. do not get charged when not in use)

All you have to do is set your minimum amount of nodes to zero and you should be set.

Hope this helps!

-- Anthony Leo
Source: StackOverflow

11/2/2019

You can configure the cluster autoscaler and specify a minimum of 0 nodes for your node pool(s).

From the docs about Minimum and maximum node pool size :

Note: 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.

You can use the following command to configure the autoscaler on an existing cluster my-cluster :

gcloud container clusters update my-cluster \
    --zone us-central1-a \ # if zonal, region otherwise
    --enable-autoscaling --min-nodes 0 --max-nodes 3
-- norbjd
Source: StackOverflow