I have a GKE cluster v1.19 that has a deployment that can run on GPU or CPU only nodes.
I have 2 node pools, both preemptive so nodes can be unavailable:
- GPU
- CPU Only
I wish to use the GPU node pool as long as GPU nodes are available. If there are no available GPU nodes I wish to assign those pods to a node with CPU only.
My current yaml for the deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: NAME
namespace: NAMESPACE
spec:
selector:
matchLabels:
app: NAME
template:
metadata:
labels:
app: NAME
spec:
nodeSelector:
cloud.google.com/gke-preemptible: "true"
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: cloud.google.com/gke-accelerator
operator: In
values:
- nvidia-tesla-t4
containers:
- name: NAME
image: IMAGE
resources:
requests:
memory: 28.0Gi
cpu: 3000m
limits:
cpu: 4000m
nvidia.com/gpu: 1
tolerations:
- effect: NoSchedule
key: nvidia.com/gpu
operator: Exists
The above yaml allows the pod to be assigned to a GPU node but not to a CPU node. Correct me if I am wrong, I have to set limits: nvidia.com/gpu: 1 in order to use the gpu, but this requires the node to have nvidia.com/gpu so it can't be assigned to CPU only node.
How can I achieve such behavior?