Google Cloud Kubernetes cost when rescaled to 0 nodes

8/2/2018

I have a batch job that I want to run on a Kubernetes cluster on Google Cloud. That job has to be run periodically, say once a week and takes a day to complete. From the doc:

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. However, while a node pool can scale to a zero size, the overall cluster size does not scale down to zero nodes (as at least one node is always required to run system Pods).

My question is, will it still generate costs to have this cluster if it is scaled down to 0 nodes? From what I understand, the cluster size won't be null hence costs would still be generated.

If that is the case, what would be the correct approach to minimize my costs? Should I periodically create/delete the cluster before/after running the job?

-- xEc
google-cloud-platform
kubernetes

1 Answer

8/3/2018

If you provision Kubernetes cluster dynamically, as far as you can rebuild cluster environment without any dependencies on the worker Nodes from scratch, Autoscaling down to zero Nodes will be a good solution, whereas Kubernetes master Nodes (system Pods) are not charged in GKE, according to the Price page.

You can create node-pools:

gcloud container node-pools create ${CLUSTER_NAME}-pool \
    --cluster ${CLUSTER_NAME} \
    --enable-autoscaling --min-nodes 0 --max-nodes 10 \
    --zone ${INSTANCE_ZONE}

and then force scaling down on demand:

gcloud container clusters resize ${CLUSTER_NAME} --size=0 [--node-pool=${CLUSTER_NAME}-pool]

Also get yourself familiar with this Document, it describes the types of Pods which can prevent Cluster Autoscaler from removing Node.

-- mk_sta
Source: StackOverflow