I have a GKE cluster running with a preemptible VM pool.
When I create a deployment with podAntiAffinity
, I would like the pods to be created in all available nodes. However, I have noticed that if the number of replicas requested is superior than the number of VMs available, more VMs are spawned in the preemptible pool to match the number of pods.
Is there a way to prevent preemptible VMs creation with podAntiAffinity
?
My deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myApp
namespace: myNamespace
labels:
k8s-app: myApp
spec:
replicas: 5
selector:
matchLabels:
k8s-app: myApp
template:
metadata:
labels:
k8s-app: myApp
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- myApp
topologyKey: kubernetes.io/hostname
...
Thanks for your help.