Documentation
¶
Overview ¶
Package merge defines the interface for merging scheduling constraints from a pod's spec with those defined in a SchedulingClass custom resource.
The flow is:
- Read the pod's annotation "scheduler.cozystack.io/scheduling-class" to identify the SchedulingClass CR.
- Fetch the SchedulingClass resource from the cluster.
- Merge the CR's constraints with the pod's own spec-level constraints.
- Return the merged result for use by the scheduling plugin.
Index ¶
Constants ¶
const SchedulingClassAnnotation = "scheduler.cozystack.io/scheduling-class"
SchedulingClassAnnotation is the pod annotation that references a SchedulingClass CR by name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConstraintMerger ¶
type ConstraintMerger interface {
// MergeInterPodAffinity returns the merged inter-pod affinity terms for the
// given pod. It reads the pod's annotation to find the SchedulingClass CR,
// parses both the pod spec and CR terms, and returns the combined result.
// If no SchedulingClass annotation is present, it returns nil.
MergeInterPodAffinity(pod *v1.Pod) (*InterPodAffinityTerms, error)
// MergeNodeAffinity returns the merged node affinity for the given pod.
// It combines pod.Spec.NodeSelector, pod.Spec.Affinity.NodeAffinity, and
// the SchedulingClass CR's node affinity terms.
// If no SchedulingClass annotation is present, it returns nil (use pod spec as-is).
MergeNodeAffinity(pod *v1.Pod) (*NodeAffinityTerms, error)
// MergeTopologySpreadConstraints returns the merged topology spread constraints.
// It appends the CR's constraints to those from pod.Spec.TopologySpreadConstraints.
// If no SchedulingClass annotation is present, it returns nil (use pod spec as-is).
MergeTopologySpreadConstraints(pod *v1.Pod) (*TopologySpreadTerms, error)
}
ConstraintMerger fetches a SchedulingClass CR for a pod and merges its constraints with those already present on the pod spec.
func SharedMerger ¶
SharedMerger returns a shared ConstraintMerger backed by a dynamic informer for SchedulingClass resources. Safe to call from multiple goroutines.
type InterPodAffinityTerms ¶
type InterPodAffinityTerms struct {
RequiredAffinityTerms []framework.AffinityTerm
RequiredAntiAffinityTerms []framework.AffinityTerm
PreferredAffinityTerms []framework.WeightedAffinityTerm
PreferredAntiAffinityTerms []framework.WeightedAffinityTerm
}
InterPodAffinityTerms holds the merged set of inter-pod affinity and anti-affinity terms for a single pod, combining pod spec and SchedulingClass.
type NodeAffinityTerms ¶
type NodeAffinityTerms struct {
// NodeSelector is the merged result of pod.Spec.NodeSelector and the CR's
// node selector requirements. It is nil if neither source has any.
NodeSelector map[string]string
// RequiredNodeAffinity is the merged node selector from both the pod spec
// and the SchedulingClass CR.
RequiredNodeAffinity *v1.NodeSelector
// PreferredNodeAffinity is the merged list of preferred scheduling terms.
PreferredNodeAffinity []v1.PreferredSchedulingTerm
}
NodeAffinityTerms holds the merged set of node affinity terms for a single pod, combining pod spec and SchedulingClass.
type TopologySpreadTerms ¶
type TopologySpreadTerms struct {
Constraints []v1.TopologySpreadConstraint
}
TopologySpreadTerms holds the merged set of topology spread constraints for a single pod, combining pod spec and SchedulingClass.