Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractClusterNames(clusters []*fedcorev1a1.FederatedCluster) []string
- func FindMatchingUntoleratedTaint(taints []corev1.Taint, tolerations []corev1.Toleration, ...) (corev1.Taint, bool)
- func GetKatalystResources(r *Resource) map[corev1.ResourceName]int64
- func GetNonzeroRequestForResource(resource corev1.ResourceName, requests *corev1.ResourceList) int64
- func GetNonzeroRequests(requests *corev1.ResourceList) (int64, int64)
- func IsAttachableVolumeResourceName(name corev1.ResourceName) bool
- func IsExtendedResourceName(name corev1.ResourceName) bool
- func IsHugePageResourceName(name corev1.ResourceName) bool
- func IsNativeResource(name corev1.ResourceName) bool
- func IsPrefixedNativeResource(name corev1.ResourceName) bool
- func IsScalarResourceName(name corev1.ResourceName) bool
- func MaxInt64(a int64, b int64) int64
- func MinInt64(a int64, b int64) int64
- func PreCheck(ctx context.Context, su *SchedulingUnit, cluster *fedcorev1a1.FederatedCluster) error
- func TolerationsTolerateTaint(tolerations []corev1.Toleration, taint *corev1.Taint) bool
- type Affinity
- type AutoMigrationInfo
- type AutoMigrationSpec
- type ClusterAffinity
- type ClusterReplicas
- type ClusterReplicasList
- type ClusterScore
- type ClusterScoreList
- type ClusterSelector
- type ClusterToResultMap
- type Code
- type CustomMigrationInfo
- type CustomMigrationSpec
- type Diagnosis
- type FilterPlugin
- type FitError
- type Framework
- type Handle
- type InsufficientResource
- type MigrationConfig
- type Plugin
- type PluginToClusterScore
- type PreferredSchedulingTerm
- type ReplicasMigration
- type ReplicasPlugin
- type Resource
- func (r *Resource) Add(rl corev1.ResourceList)
- func (r *Resource) AddScalar(name corev1.ResourceName, quantity int64)
- func (r *Resource) Clone() *Resource
- func (r *Resource) HasScalarResource(name corev1.ResourceName) bool
- func (r *Resource) ResourceList() corev1.ResourceList
- func (r *Resource) SetMaxResource(rl corev1.ResourceList)
- func (r *Resource) SetScalar(name corev1.ResourceName, quantity int64)
- func (r *Resource) Sub(rl corev1.ResourceList) error
- type ResourceName
- type ResourceToValueMap
- type ResourceToWeightMap
- type Result
- func (s *Result) AsError() error
- func (s *Result) Code() Code
- func (s *Result) FailedPlugin() string
- func (s *Result) IsSuccess() bool
- func (s *Result) Message() string
- func (s *Result) Reasons() []string
- func (s *Result) SetFailedPlugin(plugin string)
- func (s *Result) WithFailedPlugin(plugin string) *Result
- type SchedulingUnit
- type ScoreExtensions
- type ScorePlugin
- type SelectPlugin
- type UnavailableCluster
- type WorkloadMigration
Constants ¶
const ( // DefaultMilliCPURequest defines default milli cpu request number. DefaultMilliCPURequest int64 = 100 // 0.1 core // DefaultMemoryRequest defines default memory request size. DefaultMemoryRequest int64 = 200 * 1024 * 1024 // 200 MB )
For each of these resources, a pod that doesn't request the resource explicitly will be treated as having requested the amount indicated below, for the purpose of computing priority only. This ensures that when scheduling zero-request pods, such pods will not all be scheduled to the machine with the smallest in-use request, and that when scheduling regular pods, such pods will not see zero-request pods as consuming no resources whatsoever. We chose these values to be similar to the resources that we give to cluster addon pods (#10653). But they are pretty arbitrary. As described in #11713, we use request instead of limit to deal with resource requirements.
const ( // MaxClusterScore is the maximum score a Score plugin is expected to return. MaxClusterScore int64 = 100 // MinClusterScore is the minimum score a Score plugin is expected to return. MinClusterScore int64 = 0 // MaxTotalScore is the maximum total score. MaxTotalScore int64 = math.MaxInt64 )
const (
// NoClusterAvailableMsg is used to format message when no clusters available.
NoClusterAvailableMsg = "0/%v clusters are available"
)
const (
ResourceGPU = corev1.ResourceName("nvidia.com/gpu")
)
Variables ¶
var DefaultRatio int64 = 1
DefaultRatio as the ratio of any unknown requested resources
var DefaultRequestedRatioResources = ResourceToWeightMap{corev1.ResourceMemory: 1, corev1.ResourceCPU: 1, ResourceGPU: 4}
DefaultRequestedRatioResources is an empirical value derived from practice.
Functions ¶
func ExtractClusterNames ¶
func ExtractClusterNames(clusters []*fedcorev1a1.FederatedCluster) []string
func FindMatchingUntoleratedTaint ¶
func FindMatchingUntoleratedTaint( taints []corev1.Taint, tolerations []corev1.Toleration, inclusionFilter taintsFilterFunc, ) (corev1.Taint, bool)
FindMatchingUntoleratedTaint checks if the given tolerations tolerates all the filtered taints, and returns the first taint without a toleration Returns true if there is an untolerated taint Returns false if all taints are tolerated
func GetKatalystResources ¶
func GetKatalystResources(r *Resource) map[corev1.ResourceName]int64
func GetNonzeroRequestForResource ¶
func GetNonzeroRequestForResource(resource corev1.ResourceName, requests *corev1.ResourceList) int64
GetNonzeroRequestForResource returns the default resource request if none is found or what is provided on the request.
func GetNonzeroRequests ¶
func GetNonzeroRequests(requests *corev1.ResourceList) (int64, int64)
GetNonzeroRequests returns the default cpu and memory resource request if none is found or what is provided on the request.
func IsAttachableVolumeResourceName ¶
func IsAttachableVolumeResourceName(name corev1.ResourceName) bool
func IsExtendedResourceName ¶
func IsExtendedResourceName(name corev1.ResourceName) bool
IsExtendedResourceName returns true if: 1. the resource name is not in the default namespace; 2. resource name does not have "requests." prefix, to avoid confusion with the convention in quota 3. it satisfies the rules in IsQualifiedName() after converted into quota resource name
func IsHugePageResourceName ¶
func IsHugePageResourceName(name corev1.ResourceName) bool
IsHugePageResourceName returns true if the resource name has the huge page resource prefix.
func IsNativeResource ¶
func IsNativeResource(name corev1.ResourceName) bool
IsNativeResource returns true if the resource name is in the *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are implicitly in the kubernetes.io/ namespace.
func IsPrefixedNativeResource ¶
func IsPrefixedNativeResource(name corev1.ResourceName) bool
IsPrefixedNativeResource returns true if the resource name is in the *kubernetes.io/ namespace.
func IsScalarResourceName ¶
func IsScalarResourceName(name corev1.ResourceName) bool
Extended and Hugepages resources
func PreCheck ¶
func PreCheck(ctx context.Context, su *SchedulingUnit, cluster *fedcorev1a1.FederatedCluster) error
func TolerationsTolerateTaint ¶
func TolerationsTolerateTaint(tolerations []corev1.Toleration, taint *corev1.Taint) bool
TolerationsTolerateTaint checks if taint is tolerated by any of the tolerations.
Types ¶
type Affinity ¶
type Affinity struct {
// Describes cluster affinity scheduling rules for the scheduling unit.
ClusterAffinity *ClusterAffinity `json:"clusterAffinity,omitempty"`
}
Affinity is a group of affinity scheduling rules.
type AutoMigrationInfo ¶
type AutoMigrationInfo struct {
// Describes the estimated max number of replicas a cluster can accommodate.
EstimatedCapacity map[string]int64 `json:"estimatedCapacity,omitempty"`
ScheduledReplicas map[string]int64 `json:"scheduledReplicas,omitempty"`
}
AutoMigrationInfo contains information related to auto migration.
type AutoMigrationSpec ¶
type AutoMigrationSpec struct {
Info *AutoMigrationInfo
KeepUnschedulableReplicas bool
}
type ClusterAffinity ¶
type ClusterAffinity struct {
// If the affinity requirements specified by this field are not met at
// scheduling time, the scheduling unit will not be scheduled onto the cluster.
RequiredDuringSchedulingIgnoredDuringExecution *ClusterSelector `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"`
// The scheduler will prefer to schedule scheduling units to clusters that satisfy
// the affinity expressions specified by this field, but it may choose
// a cluster that violates one or more of the expressions. The cluster that is
// most preferred is the one with the greatest sum of weights, i.e.
// for each cluster that meets all of the scheduling requirements (resource
// request, requiredDuringScheduling affinity expressions, etc.),
// compute a sum by iterating through the elements of this field and adding
// "weight" to the sum if the cluster matches the corresponding matchExpressions; the
// cluster(s) with the highest sum are the most preferred.
// +optional
PreferredDuringSchedulingIgnoredDuringExecution []PreferredSchedulingTerm `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty"`
}
ClusterAffinity is a group of node affinity scheduling rules.
type ClusterReplicas ¶
type ClusterReplicas struct {
Cluster *fedcorev1a1.FederatedCluster
Replicas int64
}
type ClusterReplicasList ¶
type ClusterReplicasList []ClusterReplicas
type ClusterScore ¶
type ClusterScore struct {
Cluster *fedcorev1a1.FederatedCluster
Score int64
}
type ClusterScoreList ¶
type ClusterScoreList []ClusterScore
type ClusterSelector ¶
type ClusterSelector struct {
// A list of cluster selector terms. The terms are ORed.
ClusterSelectorTerms []fedcorev1a1.ClusterSelectorTerm `json:"clusterSelectorTerms"`
}
ClusterSelector represents the union of the results of one or more label queries over a set of clusters; that is, it represents the OR of the selectors represented by the cluster selector terms.
type ClusterToResultMap ¶
ClusterToResultMap declares map from cluster name to its result.
type Code ¶
type Code int
Code is the Status code/type which is returned from plugins.
const ( // Success means that plugin ran correctly and found resource schedulable. // NOTE: A nil status is also considered as "Success". Success Code = iota // Unschedulable is used when a plugin finds the resource unschedulable. // The accompanying status message should explain why the it is unschedulable. Unschedulable // Error is used for internal plugin errors, unexpected input, etc. Error )
These are predefined codes used in a Status.
type CustomMigrationInfo ¶
type CustomMigrationInfo struct {
// Describes the max number of replicas a cluster can accommodate.
// Different from `maxReplicas` in policy, LimitedCapacity is not affected by `avoidDisruption`
// and is a constraint that must be satisfied.
LimitedCapacity map[string]int64 `json:"limitedCapacity,omitempty"`
UnavailableClusters []UnavailableCluster `json:"unavailableClusters,omitempty"`
}
type CustomMigrationSpec ¶
type CustomMigrationSpec struct {
Info *CustomMigrationInfo
}
type Diagnosis ¶
type Diagnosis struct {
ClusterToResultMap ClusterToResultMap
UnschedulablePlugins sets.Set[string]
}
Diagnosis records the details to diagnose a scheduling failure.
type FilterPlugin ¶
type FilterPlugin interface {
Plugin
// Filter is called by the scheduling framework.
Filter(context.Context, *SchedulingUnit, *fedcorev1a1.FederatedCluster) *Result
}
FilterPlugin is an interface for filter plugins. These filters are used to filter out clusters that are not fit for the resource.
type Framework ¶
type Framework interface {
RunFilterPlugins(context.Context, *SchedulingUnit, *fedcorev1a1.FederatedCluster) *Result
RunScorePlugins(context.Context, *SchedulingUnit, []*fedcorev1a1.FederatedCluster) (PluginToClusterScore, *Result)
RunSelectClustersPlugin(context.Context, *SchedulingUnit, ClusterScoreList) ([]*fedcorev1a1.FederatedCluster, *Result)
RunReplicasPlugin(context.Context, *SchedulingUnit, []*fedcorev1a1.FederatedCluster) (ClusterReplicasList, *Result)
}
type InsufficientResource ¶
type InsufficientResource struct {
ResourceName corev1.ResourceName
// We explicitly have a parameter for reason to avoid formatting a message on the fly
// for common resources, which is expensive for cluster autoscaler simulations.
Reason string
Requested int64
Used int64
Capacity int64
}
InsufficientResource describes what kind of resource limit is hit and caused the pod to not fit the node.
type MigrationConfig ¶
type MigrationConfig struct {
// Describes the migration configuration for replicas in member clusters.
ReplicasMigrations []ReplicasMigration `json:"replicasMigrations,omitempty"`
// Describes the migration configuration for workloads in member clusters.
WorkloadMigrations []WorkloadMigration `json:"workloadMigrations,omitempty"`
}
type Plugin ¶
type Plugin interface {
Name() string
}
Plugin is the parent type for all the scheduling framework plugins.
type PluginToClusterScore ¶
type PluginToClusterScore map[string]ClusterScoreList
type PreferredSchedulingTerm ¶
type PreferredSchedulingTerm struct {
// Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.
Weight int32 `json:"weight"`
// A node selector term, associated with the corresponding weight.
Preference fedcorev1a1.ClusterSelectorTerm `json:"preference"`
}
An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).
type ReplicasMigration ¶
type ReplicasMigration struct {
Cluster string `json:"cluster"`
// Describes the max number of replicas a cluster can accommodate.
// Different from `maxReplicas` in policy, LimitedCapacity is not affected by `avoidDisruption`
// and is a constraint that must be satisfied.
LimitedCapacity *int64 `json:"limitedCapacity"`
}
type ReplicasPlugin ¶
type ReplicasPlugin interface {
Plugin
ReplicaScheduling(context.Context, *SchedulingUnit, []*fedcorev1a1.FederatedCluster) (ClusterReplicasList, *Result)
}
type Resource ¶
type Resource struct {
MilliCPU int64 `json:"millicpu"`
Memory int64 `json:"memory"`
EphemeralStorage int64 `json:"ephemeralStorage"`
// ScalarResources
ScalarResources map[corev1.ResourceName]int64 `json:"scalarResources"`
}
Resource is a collection of compute resource.
func GetResourceRequest ¶
func NewResource ¶
func NewResource(rl corev1.ResourceList) *Resource
NewResource creates a Resource from ResourceList
func (*Resource) Add ¶
func (r *Resource) Add(rl corev1.ResourceList)
Add adds ResourceList into Resource.
func (*Resource) AddScalar ¶
func (r *Resource) AddScalar(name corev1.ResourceName, quantity int64)
AddScalar adds a resource by a scalar value of this resource.
func (*Resource) HasScalarResource ¶
func (r *Resource) HasScalarResource(name corev1.ResourceName) bool
HasScalarResource checks if Resource has the given scalar resource.
func (*Resource) ResourceList ¶
func (r *Resource) ResourceList() corev1.ResourceList
ResourceList returns a resource list of this resource.
func (*Resource) SetMaxResource ¶
func (r *Resource) SetMaxResource(rl corev1.ResourceList)
SetMaxResource compares with ResourceList and takes max value for each Resource.
type ResourceName ¶
type ResourceName string
type ResourceToValueMap ¶
type ResourceToValueMap map[corev1.ResourceName]int64
type ResourceToWeightMap ¶
type ResourceToWeightMap map[corev1.ResourceName]int64
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result indicates the result of running a plugin. It consists of a code, a message and (optionally) an error. When the status code is not `Success`, the reasons should explain why.
func DefaultNormalizeScore ¶
func DefaultNormalizeScore(maxPriority int64, reverse bool, scores ClusterScoreList) *Result
DefaultNormalizeScore generates a Normalize Score function that can normalize the scores to [0, maxPriority]. If reverse is set to true, it reverses the scores by subtracting it from maxPriority.
func (*Result) AsError ¶
AsError returns nil if the Result is a success; otherwise returns an "error" object with a concatenated message on reasons of the Result.
func (*Result) FailedPlugin ¶
FailedPlugin returns the failed plugin name.
func (*Result) IsSuccess ¶
IsSuccess returns true if and only if "Result" is nil or Code is "Success".
func (*Result) SetFailedPlugin ¶
SetFailedPlugin sets the given plugin name to s.failedPlugin.
func (*Result) WithFailedPlugin ¶
WithFailedPlugin sets the given plugin name to s.failedPlugin, and returns the given result object.
type SchedulingUnit ¶
type SchedulingUnit struct {
GroupVersion schema.GroupVersion
Kind string
Resource string
Namespace string
Name string
Labels map[string]string
Annotations map[string]string
// Only care about the requests resources
// TODO(all), limit resources, Best Effort resources
// The Resource and total replica could be deliver by resource type
// or define by annotations
// Describes the schedule request
DesiredReplicas *int64
ResourceRequest Resource
// Describes the current scheduling state
CurrentClusters map[string]*int64
AutoMigration *AutoMigrationSpec
CustomMigration CustomMigrationSpec
// Controls the scheduling behavior
SchedulingMode fedcorev1a1.SchedulingMode
ReplicasStrategy fedcorev1a1.ReplicasStrategy
StickyCluster bool
AvoidDisruption bool
// Used to filter/select clusters
ClusterSelector map[string]string
ClusterNames map[string]struct{}
Affinity *Affinity
Tolerations []corev1.Toleration
MaxClusters *int64
MinReplicas map[string]int64
MaxReplicas map[string]int64
Weights map[string]int64
Priorities map[string]int64
EnableKatalystSupport bool
}
func (*SchedulingUnit) Key ¶
func (s *SchedulingUnit) Key() string
type ScoreExtensions ¶
type ScoreExtensions interface {
// NormalizeScore is called for all cluster scores produced by the same plugin's "Score"
// method. A successful run of NormalizeScore will update the scores list and return
// a success status.
NormalizeScore(context.Context, ClusterScoreList) *Result
}
ScoreExtensions is an interface for Score extended functionality.
type ScorePlugin ¶
type ScorePlugin interface {
Plugin
// Score is called on each filtered Cluster. It must return success and an integer
// indicating the rank of the cluster. All scoring plugins must return success or
// the pod will be rejected.
Score(context.Context, *SchedulingUnit, *fedcorev1a1.FederatedCluster) (int64, *Result)
// ScoreExtensions returns a ScoreExtensions interface if it implements one, or nil if it does not.
ScoreExtensions() ScoreExtensions
}
ScorePlugin is an interface that must be implemented by "Score" plugins to rank clusters that passed the filtering phase.
type SelectPlugin ¶
type SelectPlugin interface {
Plugin
SelectClusters(context.Context, *SchedulingUnit, ClusterScoreList) (ClusterScoreList, *Result)
}
type UnavailableCluster ¶
type UnavailableCluster struct {
}