Skip to main content

AddPreferredNodeSelectorRequirements

Appends the provided v1.NodeSelectorRequirement objects to an existing v1.Affinity object's list of preferred scheduling terms. See: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity-weight for how weights are used during scheduling.

def AddPreferredNodeSelectorRequirements(
base: *v1.Affinity,
weight: int32,
new: ...v1.NodeSelectorRequirement
)

Appends the provided v1.NodeSelectorRequirement objects to an existing v1.Affinity object's list of preferred scheduling terms. This function is used to specify node affinity preferences during pod scheduling, allowing pods to be preferentially scheduled on nodes that satisfy certain criteria.

Parameters

NameTypeDescription
base*v1.AffinityThe base v1.Affinity object to which the new preferred scheduling terms will be added. If its NodeAffinity field is nil, it will be initialized.
weightint32The weight associated with the preferred scheduling term. Higher weights indicate a stronger preference for nodes matching the criteria. See Kubernetes documentation for how weights are used during scheduling.
new...v1.NodeSelectorRequirementOne or more v1.NodeSelectorRequirement objects that define the criteria for node selection. These requirements specify labels that nodes must have to be considered for preferred scheduling.