mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Use metadata.name instead of hostname label when setting affinity
This commit is contained in:
parent
66329fcea9
commit
900034e5ed
@ -931,16 +931,8 @@ func SetNodeAffinityRequirement(nodeSelection *NodeSelection, operator v1.NodeSe
|
|||||||
}
|
}
|
||||||
nodeSelection.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(nodeSelection.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms,
|
nodeSelection.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(nodeSelection.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms,
|
||||||
v1.NodeSelectorTerm{
|
v1.NodeSelectorTerm{
|
||||||
// https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity warns
|
MatchFields: []v1.NodeSelectorRequirement{
|
||||||
// that "the value of kubernetes.io/hostname may be the same as the Node name in some environments and a different value in other environments".
|
{Key: "metadata.name", Operator: operator, Values: []string{nodeName}},
|
||||||
// So this might be cleaner:
|
|
||||||
// MatchFields: []v1.NodeSelectorRequirement{
|
|
||||||
// {Key: "name", Operator: v1.NodeSelectorOpNotIn, Values: []string{nodeName}},
|
|
||||||
// },
|
|
||||||
// However, "name", "Name", "ObjectMeta.Name" all got rejected with "not a valid field selector key".
|
|
||||||
|
|
||||||
MatchExpressions: []v1.NodeSelectorRequirement{
|
|
||||||
{Key: "kubernetes.io/hostname", Operator: operator, Values: []string{nodeName}},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user