We have a GKE cluster with autoscaling enabled. We are having google schedulers to shut down instances daily at a specific time. This also shuts down the GKE nodes. Since these clusters has autoscaling enabled and has a minimum node count, the nodes are getting recreated to match the minimal level, even after they are shut down by the script. Hence we are temporarily making the node count to 0 in the cluster and manually changing it back to the required number, when the nodes need to be started. When the node count is made 0, the original nodes are deleted from the cluster and new nodes are created when nodes are started. Is there any way in which nodes can just be shut down through the scripts(like normal GCP instances) instead of deleting and re-creating? There is a functionality in AWS autoscaling group where the suspend settings can be changed. So is there anything similar in GCP as well?
When you are using
GKE Cluster Autoscaler
you will change nodes number specified in your CA configuration based on some metrics.As was mentioned in GKE docs - Decreasing the size of your cluster.
In this situation when you manually change node pool to lower than it was specified in configuration,
Cluster autoscaler
mechanism worked as designed and change number of nodes to minimal.As workaround for this situation you could consider to turn off
Cluster Autoscaler
before manually resizing the node pool. When you would need autoscaling of the nodes you would need to runCA
again.Just for additional information, when you are using
Cluster Autoscaling
you can also use Horizontal Pod Autoscaler.