k8s.io/kubernetes@v1.29.3/pkg/scheduler/framework/extender.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package framework
    18  
    19  import (
    20  	v1 "k8s.io/api/core/v1"
    21  	extenderv1 "k8s.io/kube-scheduler/extender/v1"
    22  )
    23  
    24  // Extender is an interface for external processes to influence scheduling
    25  // decisions made by Kubernetes. This is typically needed for resources not directly
    26  // managed by Kubernetes.
    27  type Extender interface {
    28  	// Name returns a unique name that identifies the extender.
    29  	Name() string
    30  
    31  	// Filter based on extender-implemented predicate functions. The filtered list is
    32  	// expected to be a subset of the supplied list.
    33  	// The failedNodes and failedAndUnresolvableNodes optionally contains the list
    34  	// of failed nodes and failure reasons, except nodes in the latter are
    35  	// unresolvable.
    36  	Filter(pod *v1.Pod, nodes []*v1.Node) (filteredNodes []*v1.Node, failedNodesMap extenderv1.FailedNodesMap, failedAndUnresolvable extenderv1.FailedNodesMap, err error)
    37  
    38  	// Prioritize based on extender-implemented priority functions. The returned scores & weight
    39  	// are used to compute the weighted score for an extender. The weighted scores are added to
    40  	// the scores computed by Kubernetes scheduler. The total scores are used to do the host selection.
    41  	Prioritize(pod *v1.Pod, nodes []*v1.Node) (hostPriorities *extenderv1.HostPriorityList, weight int64, err error)
    42  
    43  	// Bind delegates the action of binding a pod to a node to the extender.
    44  	Bind(binding *v1.Binding) error
    45  
    46  	// IsBinder returns whether this extender is configured for the Bind method.
    47  	IsBinder() bool
    48  
    49  	// IsInterested returns true if at least one extended resource requested by
    50  	// this pod is managed by this extender.
    51  	IsInterested(pod *v1.Pod) bool
    52  
    53  	// ProcessPreemption returns nodes with their victim pods processed by extender based on
    54  	// given:
    55  	//   1. Pod to schedule
    56  	//   2. Candidate nodes and victim pods (nodeNameToVictims) generated by previous scheduling process.
    57  	// The possible changes made by extender may include:
    58  	//   1. Subset of given candidate nodes after preemption phase of extender.
    59  	//   2. A different set of victim pod for every given candidate node after preemption phase of extender.
    60  	ProcessPreemption(
    61  		pod *v1.Pod,
    62  		nodeNameToVictims map[string]*extenderv1.Victims,
    63  		nodeInfos NodeInfoLister,
    64  	) (map[string]*extenderv1.Victims, error)
    65  
    66  	// SupportsPreemption returns if the scheduler extender support preemption or not.
    67  	SupportsPreemption() bool
    68  
    69  	// IsIgnorable returns true indicates scheduling should not fail when this extender
    70  	// is unavailable. This gives scheduler ability to fail fast and tolerate non-critical extenders as well.
    71  	IsIgnorable() bool
    72  }