title: GKE does not scale to/from 0 when autoscaling enabled
body: <p>I want to run a CronJob on my GKE in order to perform a batch operation on a daily basis. The ideal scenario would be for my cluster to scale to 0 nodes when the job is not running and to dynamically scale to 1 node and run the job on it every time the schedule is met.</p>
  
  <p>I am first trying to achieve this by using a simple CronJob found in the <a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/" rel="nofollow noreferrer">kubernetes</a> doc that only prints the current time and terminates. </p>
  
  <p>I first created a cluster with the following command:</p>
  
  <pre><code>gcloud container clusters create $CLUSTER_NAME \
      --enable-autoscaling \
      --min-nodes 0 --max-nodes 1 --num-nodes 1 \
      --zone $CLUSTER_ZONE
  </code></pre>
  
  <p>Then, I created a CronJob with the following description:</p>
  
  <pre><code>apiVersion: batch/v1beta1
  kind: CronJob
  metadata:
    name: hello
  spec:
    schedule: "1 * * * *"
    jobTemplate:
      spec:
        template:
          spec:
            containers:
            - name: hello
              image: busybox
              args:
              - /bin/sh
              - -c
              - date; echo Hello from the Kubernetes cluster
            restartPolicy: Never
  </code></pre>
  
  <p>The job is scheduled to run every hour and to print the current time before terminating.</p>
  
  <p>First thing, I wanted to create the cluster with 0 nodes but setting <code>--num-nodes 0</code> results in an error. Why is it so? Note that I can manually scale down the cluster to 0 nodes after it has been created.</p>
  
  <p>Second, if my cluster has 0 nodes, the job won't be scheduled because the cluster does not scale to 1 node automatically but instead gives the following error: </p>
  
  <blockquote>
    <p>Cannot schedule pods: no nodes available to schedule pods.</p>
  </blockquote>
  
  <p>Third, if my cluster has 1 node, the job runs normally but after that, the cluster won't scale down to 0 nodes but stay with 1 node instead. I let my cluster run for two successive jobs and it did not scale down in between. I assume one hour should be long enough for the cluster to do so.</p>
  
  <p>What am I missing?</p>
  
  <p>EDIT: I've got it to work and detailed my solution <a href="https://stackoverflow.com/questions/49903951/node-pool-does-not-reduce-his-node-size-to-zero-although-autoscaling-is-enabled/51891485#51891485">here</a>.</p>