scheduler_interface.go 3.2 KB

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