【kubernetes/k8s概念】k8s extender scheduler

Scheduler extender

    有三种方式为 kubernetes 添加新的调度规则,包括 predicates 和 priority 功能,本文讲解第三种方式

  • 第一种,直接在 kubernetes 添加调度规则,重新编译
  • 第二种,实现自己的调度,替换 k8s 的 scheduler
  • 第三种,实现 scheduler extender,提供扩展 k8s 调度的一个能力

   当调度 pod 时,extender 通过外部的进程来预选(filter)和优选 (prioritize) 节点,extender 也可以直接实现把 pod bind 到node

   使用 extender 功能时,需要创建 scheduler policy 配置文件,配置文件指明怎样能访问到 extender

// Holds the parameters used to communicate with the extender. If a verb is unspecified/empty,
// it is assumed that the extender chose not to provide that extension.
type ExtenderConfig struct {
	// URLPrefix at which the extender is available
	URLPrefix string `json:"urlPrefix"`
	// Verb for the filter call, empty if not supported. This verb is appended to the URLPrefix when issuing the filter call to extender.
	FilterVerb string `json:"filterVerb,omitempty"`
	// Verb for the prioritize call, empty if not supported. This verb is appended to the URLPrefix when issuing the prioritize call to extender.
	PrioritizeVerb string `json:"prioritizeVerb,omitempty"`
	// Verb for the bind call, empty if not supported. This verb is appended to the URLPrefix when issuing the bind call to extender.
	// If this method is implemented by the extender, it is the extender's responsibility to bind the pod to apiserver.
	BindVerb string `json:"bindVerb,omitempty"`
	// The numeric multiplier for the node scores that the prioritize call generates.
	// The weight should be a positive integer
	Weight int `json:"weight,omitempty"`
	// EnableHttps specifies whether https should be used to communicate with the extender
	EnableHttps bool `json:"enableHttps,omitempty"`
	// TLSConfig specifies the transport layer security config
	TLSConfig *client.TLSClientConfig `json:"tlsConfig,omitempty"`
	// HTTPTimeout specifies the timeout duration for a call to the extender. Filter timeout fails the scheduling of the pod. Prioritize
	// timeout is ignored, k8s/other extenders priorities are used to select the node.
	HTTPTimeout time.Duration `json:"httpTimeout,omitempty"`
}

    extender scheduler policy 配置文件样例

{
  "predicates": [
    {
      "name": "HostName"
    },
    {
      "name": "MatchNodeSelector"
    },
    {
      "name": "PodFitsResources"
    }
  ],
  "priorities": [
    {
      "name": "LeastRequestedPriority",
      "weight": 1
    }
  ],
  "extenders": [
    {
      "urlPrefix": "http://127.0.0.1:12345/api/scheduler",
      "filterVerb": "filter",
      "enableHttps": false
    }
  ]
}

How the scheduler extender works

参考:

    https://developer.ibm.com/technologies/containers/articles/creating-a-custom-kube-scheduler/

    https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/scheduler_extender.md

发布了245 篇原创文章 · 获赞 314 · 访问量 40万+

猜你喜欢

转载自blog.csdn.net/zhonglinzhang/article/details/104555364