<p>I have created two node pools. A small one for all the google system jobs and a bigger one for my tasks. The bigger one should reduce its size to 0 after the job is done.</p>

<blockquote>
  <p><strong>The problem is:</strong> Even if there are no cron jobs, the node pool do not
  reduce his size to 0.</p>
</blockquote>

<p><strong>Creating cluster:</strong></p>

<pre><code>gcloud beta container --project "projectXY" clusters create "cluster" --zone "europe-west3-a" --username "admin" --cluster-version "1.9.6-gke.0" --machine-type "n1-standard-1" --image-type "COS" --disk-size "100" --scopes "https://www.googleapis.com/auth/cloud-platform" --num-nodes "1" --network "default" --enable-cloud-logging --enable-cloud-monitoring --subnetwork "default" --enable-autoscaling --enable-autoupgrade --min-nodes "1" --max-nodes "1"
</code></pre>

<p><strong>Creating node pool:</strong></p>

<p>The node pool should reduce its size to 0 after all tasks are done.</p>

<pre><code>gcloud container node-pools create workerpool --cluster=cluster --machine-type="n1-highmem-8", -m "n1-highmem-8" --zone=europe-west3-a, -z europe-west3-a --disk-size=100 --enable-autoupgrade --num-nodes=0 --enable-autoscaling --max-nodes=2 --min-nodes=0
</code></pre>

<p><strong>Create cron job:</strong></p>

<pre><code>kubectl create -f cronjob.yaml
</code></pre>

<p>Quoting from Google <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler" rel="nofollow noreferrer">Documentation</a>:</p>
<blockquote>
<p>&quot;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. 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).&quot;</p>
</blockquote>
<p>Notice also that:</p>
<blockquote>
<p>&quot;Cluster autoscaler also measures the usage of each node against the node pool's total demand for capacity. If a node has had no new Pods scheduled on it for a set period of time, and <strong>[this option does not work for you since it is the last node]</strong> all Pods running on that node can be scheduled onto other nodes in the pool , the autoscaler moves the Pods and deletes the node.</p>
<p>Note that cluster autoscaler works based on Pod resource requests, that is, how many resources your Pods have requested. Cluster autoscaler does not take into account the resources your Pods are actively using. Essentially, cluster autoscaler trusts that the Pod resource requests you've provided are accurate and schedules Pods on nodes based on that assumption.&quot;</p>
</blockquote>
<p><strong>Therefore I would check:</strong></p>
<ul>
<li>that your version of your Kubernetes cluster is at least 1.7</li>
<li>that there are no pods running on the last node (check every namespace, the pods that have to run on every node do no count: fluentd, kube-dns, kube-proxy), the fact that there are no cronjobs is not enough</li>
<li>that for the autoscaler is <strong>NOT</strong> enabled for the corresponding managed instance groups since they are different tools</li>
<li>that there are no pods stuck in any weird state still assigned to that node</li>
<li>that there is no pods waiting to be scheduled in the cluster</li>
</ul>
<p>If still everything  likely it is an issue with the autoscaler and you can either open a <a href="https://issuetracker.google.com/issues/new?component=187164" rel="nofollow noreferrer">private issue</a> specifying your project ID with Google since there is not much the community can do.</p>
<p>If you are interested place in the comments the link of the issue tracker and I will take a look in your project (I work for Google Cloud Platform Support)</p>
