<p>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:</p>

<blockquote>
  <p>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).</p>
</blockquote>

<p>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.</p>

<p>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?</p>

xEc
<p>If you provision Kubernetes cluster dynamically, as far as you can rebuild cluster environment without any dependencies on the worker Nodes from scratch, <code>Autoscaling</code> down to zero Nodes will be a good solution, whereas Kubernetes master Nodes (system Pods) are not charged in <code>GKE</code>, according to the <a href="https://cloud.google.com/kubernetes-engine/pricing" rel="noreferrer">Price page</a>.</p>

<p>You can create <code>node-pools</code>:</p>

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

<p>and then force scaling down on demand:</p>

<pre><code>gcloud container clusters resize ${CLUSTER_NAME} --size=0 [--node-pool=${CLUSTER_NAME}-pool]
</code></pre>

<p>Also get yourself familiar with this <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node" rel="noreferrer">Document</a>, it describes the types of Pods which can prevent <code>Cluster Autoscaler</code> from removing Node. </p>
