Reputation: 41
my use-case is to schedule a deployment only in fsn1
region nodes, unless there's an emergency and nodes of fsn1
go down, then only in that case I want to schedule as a fallback on hel1
nodes.
Unfortunately, with these rules, 5/26 total pods are still scheduled on hel1
nodes, even with weight: 1
. All nodes have same resources and only accomodate this deployment, so it's not like other deployments occupy resources of fsn1
nodes.
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: "region"
operator: "In"
values:
- "fsn1"
- weight: 1
preference:
matchExpressions:
- key: "region"
operator: "In"
values:
- "hel1"
Is there another way? I want to avoid using a custom scheduler if possible.
Upvotes: 0
Views: 105
Reputation: 367
Node affinity is conceptually similar to nodeSelector, allowing you to constrain which nodes your Pod can be scheduled on based on node labels. There are two types of node affinity:
requiredDuringSchedulingIgnoredDuringExecution: The scheduler can't schedule the Pod unless the rule is met. This functions like nodeSelector, but with a more expressive syntax.
preferredDuringSchedulingIgnoredDuringExecution: The scheduler tries to find a node that meets the rule. If a matching node is not available, the scheduler still schedules the Pod.
As mentioned in this other SO preferredDuringSchedulingIgnoredDuringExecution is not guaranteed. A scheduler will try to force a schedule but it is not guaranteed because of other factors.
Also go through this Document which might be helpful.
Upvotes: 1