You can create a Container Engine cluster or node pool that uses preemptible VMs.
Preemptible VMs are Google Compute Engine instances that last a maximum of 24 hours, but provide no availability guarantees. They are priced lower than standard Compute Engine instances, and offer the same machine types and options.
You can use preemptible VMs in your Container Engine clusters or node pools to run batch or fault-tolerant jobs that are less sensitive to the non-guaranteed nature of preemptible VMs.
Creating a Cluster or Node Pool with Preemptible Instances
To create a cluster or node pool with preemptible VMs, specify the
--preemptible option when using the
gcloud beta container cluster create or
gcloud beta container node-pools create command:
#Creating a cluster with preemptible instances gcloud beta container clusters create CLUSTER --zone ZONE --preemptible #Creating a nodepool with preemptible instances gcloud beta container node-pools create NODEPOOL --cluster CLUSTER --zone ZONE --preemptible
When a Container Engine cluster or node pool creates Compute Engine Instances, those instances
behave like a managed instance group. Creating or adding
new preemptible instances in your Container Engine cluster or node pool are subject
to the same limitations as preemptible instances in a managed instance group.
These preemptible instances also get a new kubernetes label
Kubernetes label can be used in nodeSelector for pod scheduling on specific nodes.
Here is an example selector for filtering preemptible instances:
apiVersion: v1 kind: Pod spec: nodeSelector: cloud.google.com/gke-preemptible: true
A similar selector which avoids preemptible instances will look like following:
apiVersion: v1 kind: Pod spec: nodeSelector: !cloud.google.com/gke-preemptible
Because preemptible VMs have no availability guarantees, you should design your system under the assumption that any or all of your Compute Engine instances might be preempted and become unavailable, and there are no guarantees as to when new instances will become available.
If you want to ensure that your jobs or workloads are processed even if no preemtible instances are available, you can create both non-preemptible and preemptible node pools in your Container Engine cluster.