<p>We have a GKE cluster set up on google cloud platform.</p>

<p>We have an activity that requires 'bursts' of computing power. </p>

<p>Imagine that we usually do 100 computations an hour on average, then suddently we need to be able to process 100000 in less then two minutes. However most of the time, everything is close to idle.</p>

<p>We do not want to pay for idle servers 99% of the time, and want to scale clusters depending on actual use (no data persistance needed, servers can be deleted afterwards). I looked up the documentation available on kubernetes regarding auto scaling, for adding more pods with <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">HPA</a> and adding more nodes with <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler" rel="nofollow noreferrer">cluster autoscaler</a></p>

<p>However it doesn't seem like any of these solutions would actually reduce our costs or improve performances, because they do not seem to scale past the GCP plan:</p>

<p>Imagine that we have a <a href="https://cloud.google.com/compute/all-pricing" rel="nofollow noreferrer">google plan</a> with 8 CPUs. My understanding is if we add more nodes with cluster autoscaler we will just instead of having e.g. 2 nodes using 4 CPUs each we will have 4 nodes using 2 cpus each. But the total available computing power will still be 8 CPU. 
Same reasoning go for HPA with more pods instead of more nodes.</p>

<p>If we have the 8 CPU payment plan but only use 4 of them, my understanding is we still get billed for 8 so scaling down is not really useful.</p>

<p>What we want is autoscaling to change our payment plan temporarly (imagine from n1-standard-8    to n1-standard-16) and get actual new computing power.</p>

<p>I can't believe we are the only ones with this use case but I cannot find any documentation on this anywhere! Did I misunderstand something ?</p>

<p><strong>TL;DR:</strong></p>

<ul>
<li>Create a small persistant node-pool </li>
<li>Create a powerfull node-pool that can be scaled to zero (and cease billing) while not in use.</li>
<li>Tools used:

<ul>
<li>GKE’s  <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler" rel="noreferrer">Cluster Autoscaling</a>, <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="noreferrer">Node selector</a>,  <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity" rel="noreferrer">Anti-affinity rules</a> and <a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="noreferrer">Taints and tolerations</a>.</li>
</ul></li>
</ul>

<hr>

<p><strong>GKE Pricing:</strong></p>

<ul>
<li>From <a href="https://cloud.google.com/kubernetes-engine/pricing" rel="noreferrer">GKE Pricing</a>:

<blockquote>
  <p>Starting June 6, 2020, GKE will charge a cluster management fee of $0.10 per cluster per hour. The following conditions apply to the cluster management fee:</p>
  
  <ul>
  <li>One  <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/types-of-clusters" rel="noreferrer">zonal cluster</a>  per billing account is  <strong>free</strong>.</li>
  <li>The fee is flat, irrespective of cluster size and topology.</li>
  <li>Billing is computed on a <strong>per-second basis</strong> for each cluster. The total amount is rounded to the nearest cent, at the end of each month.</li>
  </ul>
</blockquote></li>
<li><p>From <a href="https://cloud.google.com/kubernetes-engine/pricing#pricing_for_worker_nodes" rel="noreferrer">Pricing for Worker Nodes</a>:</p>

<blockquote>
  <p>GKE uses Compute Engine instances for <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture#nodes" rel="noreferrer">worker nodes in the cluster</a>. You are billed for each of those instances according to <a href="https://cloud.google.com/compute/pricing" rel="noreferrer">Compute Engine's pricing</a>, <strong>until the nodes are deleted</strong>. Compute Engine resources are billed on a per-second basis with a one-minute minimum usage cost.</p>
</blockquote></li>
<li><p>Enters, <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler" rel="noreferrer">Cluster Autoscaler</a>:</p>

<blockquote>
  <p>automatically resize your GKE cluster’s node pools based on the demands of your workloads. When demand is high, cluster autoscaler adds nodes to the node pool. When demand is low, cluster autoscaler scales back down to a minimum size that you designate. This can increase the availability of your workloads when you need it, while controlling costs.</p>
</blockquote></li>
</ul>

<hr>

<ul>
<li>Cluster Autoscaler cannot scale the entire cluster to zero, at least one node must always be available in the cluster to run system pods. </li>
<li><p>Since you already have a persistent workload, this wont be a problem, what we will do is create a new <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/node-pools" rel="noreferrer">node pool</a>:</p>

<blockquote>
  <p>A node pool is a group of nodes within a cluster that all have the same configuration. Every cluster has at least one  <em>default</em>  node pool, but you can add other node pools as needed.</p>
</blockquote></li>
<li><p>For this example I'll create two node pools:</p>

<ul>
<li>A default node pool with a fixed size of one node with a small instance size (emulating the cluster you already have).</li>
<li>A second node pool with more compute power to run the jobs (I'll call it power-pool). 

<ul>
<li>Choose the machine type with the power you need to run your AI Jobs, for this example I'll create a <code>n1-standard-8</code>.</li>
<li>This power-pool will have autoscaling set to allow max 4 nodes, minimum 0 nodes.</li>
<li>If you like to add GPUs you can check this great: <a href="https://medium.com/google-cloud/scale-your-kubernetes-cluster-to-almost-zero-with-gke-autoscaler-9c78051cbf40" rel="noreferrer">Guide Scale to almost zero + GPUs</a>.</li>
</ul></li>
</ul></li>
</ul>

<p><strong>Taints and Tolerations:</strong></p>

<ul>
<li>Only the jobs related to the AI workload will run on the power-pool, for that use a <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="noreferrer">node selector</a>  in the job pods to make sure they run in the power-pool nodes.</li>
<li>Set a <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity" rel="noreferrer">anti-affinity</a> rule to ensure that two of your training pods cannot be scheduled on the same node (optimizing the price-performance ratio, this is optional depending on your workload).</li>
<li>Add a <a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="noreferrer">taint</a> to the power-pool to avoid other workloads (and system resources) to be scheduled on the autoscalable pool.</li>
<li>Add the tolerations to the AI Jobs to let them run on those nodes.</li>
</ul>

<hr>

<p><strong>Reproduction:</strong></p>

<ul>
<li>Create the Cluster with the persistent default-pool:</li>
</ul>

<pre><code>PROJECT_ID="YOUR_PROJECT_ID"  
GCP_ZONE="CLUSTER_ZONE"  
GKE_CLUSTER_NAME="CLUSTER_NAME"  
AUTOSCALE_POOL="power-pool"  

gcloud container clusters create ${GKE_CLUSTER_NAME} \
--machine-type="n1-standard-1" \
--num-nodes=1 \
--zone=${GCP_ZONE} \
--project=${PROJECT_ID}
</code></pre>

<ul>
<li>Create the auto-scale pool:</li>
</ul>

<pre><code>gcloud container node-pools create ${GKE_BURST_POOL} \
--cluster=${GKE_CLUSTER_NAME} \
--machine-type=n1-standard-8 \
--node-labels=load=on-demand \
--node-taints=reserved-pool=true:NoSchedule \
--enable-autoscaling \
--min-nodes=0 \
--max-nodes=4 \
--zone=${GCP_ZONE} \
--project=${PROJECT_ID}
</code></pre>

<ul>
<li><p>Note about parameters:</p>

<ul>
<li><code>--node-labels=load=on-demand</code>: Add a label to the nodes in the power pool to allow selecting them in our AI job using a <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="noreferrer">node selector</a>.</li>
<li><code>--node-taints=reserved-pool=true:NoSchedule</code>: Add a  <a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="noreferrer">taint</a>  to the nodes to prevent any other workload from accidentally being scheduled in this node pool.</li>
</ul></li>
<li><p>Here you can see the two pools we created, the static pool with 1 node and the autoscalable pool with 0-4 nodes. </p></li>
</ul>

<p><a href="https://i.stack.imgur.com/1krf5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1krf5.png" alt="enter image description here"></a></p>

<p>Since we don't have workload running on the autoscalable node-pool, it shows 0 nodes running (and with no charge while there is no node in execution).</p>

<ul>
<li>Now we'll create a job that create 4 parallel pods that run for 5 minutes.

<ul>
<li>This job will have the following parameters to differentiate from normal pods:</li>
<li><code>parallelism: 4</code>: to use all 4 nodes to enhance performance</li>
<li><code>nodeSelector.load: on-demand</code>: to assign to the nodes with that label.</li>
<li><code>podAntiAffinity</code>: to declare that we do not want two pods with the same label  <code>app: greedy-job</code>  running in the same node (optional).</li>
<li><code>tolerations:</code> to match the toleration to the taint that we attached to the nodes, so these pods are allowed to be scheduled in these nodes.</li>
</ul></li>
</ul>

<pre><code>apiVersion: batch/v1  
kind: Job  
metadata:  
  name: greedy-job  
spec:  
  parallelism: 4  
  template:  
    metadata:  
      name: greedy-job  
      labels: 
        app: greedy-app  
    spec:  
      containers:  
      - name: busybox  
        image: busybox  
        args:  
        - sleep  
        - "300"  
      nodeSelector: 
        load: on-demand 
      affinity:  
        podAntiAffinity:  
          requiredDuringSchedulingIgnoredDuringExecution:  
          - labelSelector:  
              matchExpressions:  
              - key: app  
                operator: In  
                values:  
                - greedy-app  
            topologyKey: "kubernetes.io/hostname"  
      tolerations:  
      - key: reserved-pool  
        operator: Equal  
        value: "true"  
        effect: NoSchedule  
      restartPolicy: OnFailure
</code></pre>

<ul>
<li>Now that our cluster is in standby we will use the job yaml we just created (I'll call it <code>greedyjob.yaml</code>). This job will run four processes that will run in parallel and that will complete after about 5 minutes.</li>
</ul>

<pre><code>$ kubectl get nodes
NAME                                                  STATUS   ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   42m   v1.14.10-gke.27

$ kubectl get pods
No resources found in default namespace.

$ kubectl apply -f greedyjob.yaml 
job.batch/greedy-job created

$ kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
greedy-job-2xbvx   0/1     Pending   0          11s
greedy-job-72j8r   0/1     Pending   0          11s
greedy-job-9dfdt   0/1     Pending   0          11s
greedy-job-wqct9   0/1     Pending   0          11s
</code></pre>

<ul>
<li>Our job was applied, but is in pending, let's see what's going on in those pods:</li>
</ul>

<pre><code>$ kubectl describe pod greedy-job-2xbvx
...
Events:
  Type     Reason            Age                From                Message
  ----     ------            ----               ----                -------
  Warning  FailedScheduling  28s (x2 over 28s)  default-scheduler   0/1 nodes are available: 1 node(s) didn't match node selector.
  Normal   TriggeredScaleUp  23s                cluster-autoscaler  pod triggered scale-up: [{https://content.googleapis.com/compute/v1/projects/owilliam/zones/us-central1-b/instanceGroups/gke-autoscale-to-zero-clus-power-pool-564148fd-grp 0-&gt;1 (max: 4)}]
</code></pre>

<ul>
<li>The pod can't be scheduled on the current node due to the rules we defined, this triggers a Scale Up routine on our power-pool. This is a very dynamic process, after 90 seconds the first node is up and running:</li>
</ul>

<pre><code>$ kubectl get pods
NAME               READY   STATUS              RESTARTS   AGE
greedy-job-2xbvx   0/1     Pending             0          93s
greedy-job-72j8r   0/1     ContainerCreating   0          93s
greedy-job-9dfdt   0/1     Pending             0          93s
greedy-job-wqct9   0/1     Pending             0          93s

$ kubectl nodes
NAME                                                  STATUS   ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   44m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready    &lt;none&gt;   11s   v1.14.10-gke.27
</code></pre>

<ul>
<li>Since we set pod anti-affinity rules, the second pod can't be scheduled on the node that was brought up and triggers the next scale up, take a look at the events on the second pod:</li>
</ul>

<pre><code>$ k describe pod greedy-job-2xbvx
...
Events:
  Type     Reason            Age                  From                Message
  ----     ------            ----                 ----                -------
  Normal   TriggeredScaleUp  2m45s                cluster-autoscaler  pod triggered scale-up: [{https://content.googleapis.com/compute/v1/projects/owilliam/zones/us-central1-b/instanceGroups/gke-autoscale-to-zero-clus-power-pool-564148fd-grp 0-&gt;1 (max: 4)}]
  Warning  FailedScheduling  93s (x3 over 2m50s)  default-scheduler   0/1 nodes are available: 1 node(s) didn't match node selector.
  Warning  FailedScheduling  79s (x3 over 83s)    default-scheduler   0/2 nodes are available: 1 node(s) didn't match node selector, 1 node(s) had taints that the pod didn't tolerate.
  Normal   TriggeredScaleUp  62s                  cluster-autoscaler  pod triggered scale-up: [{https://content.googleapis.com/compute/v1/projects/owilliam/zones/us-central1-b/instanceGroups/gke-autoscale-to-zero-clus-power-pool-564148fd-grp 1-&gt;2 (max: 4)}]
  Warning  FailedScheduling  3s (x3 over 68s)     default-scheduler   0/2 nodes are available: 1 node(s) didn't match node selector, 1 node(s) didn't match pod affinity/anti-affinity, 1 node(s) didn't satisfy existing pods anti-affinity rules.
</code></pre>

<ul>
<li>The same process repeats until all requirements are satisfied:</li>
</ul>

<pre><code>$ kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
greedy-job-2xbvx   0/1     Pending   0          3m39s
greedy-job-72j8r   1/1     Running   0          3m39s
greedy-job-9dfdt   0/1     Pending   0          3m39s
greedy-job-wqct9   1/1     Running   0          3m39s

$ kubectl get nodes
NAME                                                  STATUS   ROLES    AGE     VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   46m     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready    &lt;none&gt;   2m16s   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-sf6q   Ready    &lt;none&gt;   28s     v1.14.10-gke.27

$ kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
greedy-job-2xbvx   0/1     Pending   0          5m19s
greedy-job-72j8r   1/1     Running   0          5m19s
greedy-job-9dfdt   1/1     Running   0          5m19s
greedy-job-wqct9   1/1     Running   0          5m19s

$ kubectl get nodes
NAME                                                  STATUS   ROLES    AGE     VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   48m     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   Ready    &lt;none&gt;   63s     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready    &lt;none&gt;   4m8s    v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-sf6q   Ready    &lt;none&gt;   2m20s   v1.14.10-gke.27

$ kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
greedy-job-2xbvx   1/1     Running   0          6m12s
greedy-job-72j8r   1/1     Running   0          6m12s
greedy-job-9dfdt   1/1     Running   0          6m12s
greedy-job-wqct9   1/1     Running   0          6m12s

$ kubectl get nodes
NAME                                                  STATUS   ROLES    AGE     VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   48m     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   Ready    &lt;none&gt;   113s    v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   Ready    &lt;none&gt;   26s     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready    &lt;none&gt;   4m58s   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-sf6q   Ready    &lt;none&gt;   3m10s   v1.14.10-gke.27
</code></pre>

<p><a href="https://i.stack.imgur.com/CRXUU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CRXUU.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/y7Bs1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/y7Bs1.png" alt="enter image description here"></a>
Here we can see that all nodes are now up and running (thus, being billed by second)</p>

<ul>
<li>Now all jobs are running, after a few minutes the jobs complete their tasks:</li>
</ul>

<pre><code>$ kubectl get pods
NAME               READY   STATUS      RESTARTS   AGE
greedy-job-2xbvx   1/1     Running     0          7m22s
greedy-job-72j8r   0/1     Completed   0          7m22s
greedy-job-9dfdt   1/1     Running     0          7m22s
greedy-job-wqct9   1/1     Running     0          7m22s

$ kubectl get pods
NAME               READY   STATUS      RESTARTS   AGE
greedy-job-2xbvx   0/1     Completed   0          11m
greedy-job-72j8r   0/1     Completed   0          11m
greedy-job-9dfdt   0/1     Completed   0          11m
greedy-job-wqct9   0/1     Completed   0          11m
</code></pre>

<ul>
<li>Once the task is completed, the autoscaler starts downsizing the cluster.</li>
<li>You can learn more about the rules for this process here: <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler" rel="noreferrer">GKE Cluster AutoScaler</a></li>
</ul>

<pre><code>$ while true; do kubectl get nodes ; sleep 60; done
NAME                                                  STATUS   ROLES    AGE     VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   54m     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   Ready    &lt;none&gt;   7m26s   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   Ready    &lt;none&gt;   5m59s   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready    &lt;none&gt;   10m     v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-sf6q   Ready    &lt;none&gt;   8m43s   v1.14.10-gke.27

NAME                                                  STATUS     ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready      &lt;none&gt;   62m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   Ready      &lt;none&gt;   15m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   Ready      &lt;none&gt;   14m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready      &lt;none&gt;   18m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-sf6q   NotReady   &lt;none&gt;   16m   v1.14.10-gke.27
</code></pre>

<ul>
<li>Once conditions are met, autoscaler flags the node as <code>NotReady</code> and starts removing them: </li>
</ul>

<pre><code>NAME                                                  STATUS     ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready      &lt;none&gt;   64m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   NotReady   &lt;none&gt;   17m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   NotReady   &lt;none&gt;   16m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   Ready      &lt;none&gt;   20m   v1.14.10-gke.27

NAME                                                  STATUS     ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready      &lt;none&gt;   65m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-39m2   NotReady   &lt;none&gt;   18m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   NotReady   &lt;none&gt;   17m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-qxkw   NotReady   &lt;none&gt;   21m   v1.14.10-gke.27

NAME                                                  STATUS     ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready      &lt;none&gt;   66m   v1.14.10-gke.27
gke-autoscale-to-zero-clus-power-pool-564148fd-ggxv   NotReady   &lt;none&gt;   18m   v1.14.10-gke.27

NAME                                                  STATUS   ROLES    AGE   VERSION
gke-autoscale-to-zero-cl-default-pool-9f6d80d3-x9lb   Ready    &lt;none&gt;   67m   v1.14.10-gke.27
</code></pre>

<hr>

<ul>
<li>Here is the confirmation that the nodes were removed from GKE and from VMs(remember that every node is a Virtual Machine billed as Compute Engine):</li>
</ul>

<p>Compute Engine: (note that <code>gke-cluster-1-default-pool</code> is from another cluster, I added it to the screenshot to show you that there is no other node from cluster <code>gke-autoscale-to-zero</code> other than the default persistent one.)
<a href="https://i.stack.imgur.com/xSjiP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xSjiP.png" alt="enter image description here"></a></p>

<p>GKE:
<a href="https://i.stack.imgur.com/N47iH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N47iH.png" alt="enter image description here"></a></p>

<hr>

<p><strong>Final Thoughts:</strong></p>

<blockquote>
  <p>When scaling down, cluster autoscaler respects scheduling and eviction rules set on Pods. These restrictions can prevent a node from being deleted by the autoscaler. A node's deletion could be prevented if it contains a Pod with any of these conditions:
  An application's <a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#how-disruption-budgets-work" rel="noreferrer">PodDisruptionBudget</a> can also prevent autoscaling; if deleting nodes would cause the budget to be exceeded, the cluster does not scale down.</p>
</blockquote>

<p>You can note that the process is really fast, in our example it took around 90 seconds to upscale a node and 5 minutes to finish downscaling a standby node, providing a HUGE improvement in your billing.</p>

<ul>
<li><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/preemptible-vms" rel="noreferrer">Preemptible VMs</a> can reduce even further your billing, but you will have to consider the kind of workload you are running:</li>
</ul>

<blockquote>
  <p><strong>Preemptible VMs</strong> are Compute Engine <a href="https://cloud.google.com/compute/docs/instances" rel="noreferrer">VM instances</a> that last a maximum of 24 hours and provide no availability guarantees. Preemptible VMs are <a href="https://cloud.google.com/compute/pricing" rel="noreferrer">priced lower</a> than standard Compute Engine VMs and offer the same <a href="https://cloud.google.com/compute/docs/machine-types" rel="noreferrer">machine types</a> and options.</p>
</blockquote>

<p>I know you are still considering the best architecture for your app.</p>

<p>Using <a href="https://cloud.google.com/appengine" rel="noreferrer">APP Engine</a> and <a href="https://cloud.google.com/ai-platform" rel="noreferrer">IA Platform</a> are optimal solutions as well, but since you are currently running your workload on GKE I wanted to show you an example as requested.</p>

<p>If you have any further questions let me know in the comments.</p>
