I am trying have kubernetes create new pods on the most requested nodes instead of pods spreading the load across available nodes. The rationale is that this simplifies scale down scenarios and relaunching of application if pods gets moved and a node gets killed during autoscaling.
The preferred strategy for descaling is - 1) Never kill a node if there is any running pod 2) New pods are created preferentially on the most requested Nodes 3) The pods will self destruct after job completion. This should, over time, result in free nodes after the tasks are completed and thus descaling will be safe and I don't need to worry about resilience of the running jobs.
For this, is there any way I can specify the NodeAffinity in the pod spec, something like:
spec:
affinity:
nodeAffinity:
RequiredDuringSchedulingIgnoredDuringExecution:
- weight: 100
nodeAffinityTerm: {MostRequestedPriority}
The above code has no effect. The documentation for NodeAffinity
doesn't specify if I can use MostRequestedPriority
in this context. MostRequestedPriority
is an option in the kubernetes scheduler service spec. But I am trying to see if I can directly put t in the pod spec, instead of creating a new custom kubernetes scheduler.