前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Kubernetes Scheduler Extender浅析

Kubernetes Scheduler Extender浅析

作者头像
runzhliu
发布2020-08-06 10:13:42
2.2K0
发布2020-08-06 10:13:42
举报
文章被收录于专栏:容器计算容器计算

https://kubernetes.io/docs/concepts/extend-kubernetes/extend-cluster/#scheduler-extensions

Scheduler 组件可以视为一种监视 watche 和将 Pod 分配 assign 到 Node 的特殊类型控制器 controller。在 Kubernetes 里,默认的 Scheduler 完全可以被替代,又或者增加多个 Scheduler 来同时或者一起调度 Pod,这在 Kuberntes 里称为 Mulitple Scheduler。

同时 Scheduler 也提供了 webhook 的机制,来让用户通过编写自己定义的 Shedueler Exetension 来为调度 Pod 去过滤 filter 和优化 prioritize 节点。

关于 Scheduler Extender 看下面官方文档就够了,这里补充一些。

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

Scheduler Extender 实际上是一个额外的调度进程,用来 Filter 和 Prioritize 节点的。所以顺理成章的,用户需要实现自己的 Filter 和 Prioritize 方法。另外 Extender 也可以实现 Bind 方法,来实现将 Pod Bind 到 Node 上的操作。

代码语言:javascript
复制
// 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"`
}

可以见到,用户需要提供一个 sheduler policy 的配置文件,其中包括了 Extender 的前缀,Filter 和 Priorize 和 Bind 等信息。

下面是一个配置文件的 json 例子。已知 predicatespriorities 两个字段的值皆为默认值,关注一下 extenders 字段的值,只有在这里配置了,Kubernetes 在调度 Pod 的时候才会过这里这一层。

代码语言:javascript
复制
{
  "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
    }
  ]
}

我们熟知的**开源的 GPU 调度插件也是基于这个机制来实现 GPU 资源的调度 gpu-share-extender 的。 关于 Scheduler Extender 的实现,其实用什么语言都能做。关键是要实现到 filter 和 prioritize 的功能。 这是一个完全用 Bash 脚本完成的 Extender rothgar/bashScheduler。

关于如何编写一个一个 Scheduler Exetender,我建议直接参考 IBM 博客的一篇文章 Create a custom Kubernetes scheduler

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-02-09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档