Kubernetes Scheduler Extender浅析
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 上的操作。
// 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 例子。已知 predicates
和 priorities
两个字段的值皆为默认值,关注一下 extenders
字段的值,只有在这里配置了,Kubernetes 在调度 Pod 的时候才会过这里这一层。
{
"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。
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Android 天气APP(二十一)滑动改变UI、增加更多天气数据展示,最多未来15天天气预报
- Android 读取csv格式数据文件
- Android LitePal的简单使用
- Android RecyclerVIew列表使用 (编辑、单选、全选、删除、动画效果+附源码)
- Android TV 焦点控制
- Kotlin学习日志(四)函数
- Kotlin学习日志(三)控制语句
- Kotlin学习日志(一)TextView、Button、Toast的使用
- Kotlin学习日志(二)数据类型
- Toast提示工具类
- RadioGroup+ViewPager +Fragment 制作APP主界面底部导航和左右滑动
- MD5加密工具类
- Kotlin修炼指南(四)
- Android Studio 安装APK在虚拟机时报 Installation failed due to: 'null' 解决
- 在Android Studio中使用Kotlin