Is it possible to create a node-pool that the scheduler will ignore by default but that can be targeted by node-selector?
If your node-pool has a static size or at least it's not auto-scaling then this is easy to accomplish.
First, taint the nodes in that pool:
kubectl taint node \
`kubectl get node -l cloud.google.com/gke-nodepool=my-pool -o name` \
dedicated=my-pool:NoSchedule
Then add affinity
and tolerations
values under spec:
in your Pod(templates) that need to be able to run on these nodes:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: dedicated
operator: In
values: ["my-pool"]
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
Then add these annotations to your Pod(templates) that need to be able to run on these nodes:
annotations:
scheduler.alpha.kubernetes.io/tolerations: >
[{"key":"dedicated", "value":"my-pool"}]
scheduler.alpha.kubernetes.io/affinity: >
{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "dedicated",
"operator": "In",
"values": ["my-pool"]
}
]
}
]
}
}
}
See the design doc for more information.
You need to add the --register-with-taints
parameter to kubelet
:
Register the node with the given list of taints (comma separated
<key>=<value>:<effect>
). No-op if register-node is false.
In another answer I gave some examples on how to persist that setting. GKE now also has specific support for tainting node pools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With