代码拉取完成,页面将自动刷新
bcs mesos方案支持多种类型的调度参数来源:
上述四种可以满足多种调度场景,其中第四种调度参数来源主要是为了满足一些动态的、变化的、从第三方系统获取的调度参数,例如:容器ip剩余资源量。 它是使用插件的方式实现的,业务可以根据自己的服务特点来定制化的实现。
import (
"github.com/Tencent/bk-bcs/bcs-common/common/plugin"
)
// plugin must implement
// func GetHostAttributes([]string) (map[string]*types.HostAttributes,error)
// func input: ip list, example: []string{"127.0.0.10","127.0.0.11","127.0.0.12"}
// func ouput: map key = ip, example: map["127.0.0.10"] = &types.HostAttributes{}
// implement func Init(para *types.InitPluginParameter) error
// func input: *types.InitPluginParameter
// func output: error
//for example
var initPara *plugin.InitPluginParameter
func Init(para *plugin.InitPluginParameter) error {
initPara = para
return nil
}
func Uninit() {
//TODO
}
func GetHostAttributes(para *plugin.HostPluginParameter) (map[string]*plugin.HostAttributes, error) {
atrrs := make(map[string]*plugin.HostAttributes)
for _, ip := range para.Ips {
hostAttr := &plugin.HostAttributes{
Ip: ip,
Attributes: make([]*plugin.Attribute, 0),
}
atrri := &plugin.Attribute{
Name: "ip-resources",
Type: plugin.ValueScalar,
Scalar: plugin.Value_Scalar{Value: 10},
}
hostAttr.Attributes = append(hostAttr.Attributes, atrri)
atrrs[ip] = hostAttr
}
return atrrs, nil
}
上述是一个插件实现的例子,插件只需要实现方法GetHostAttributes即可。然后编译为so文件
go build -buildmode=plugin -o xxxx.so xxxxx.go
并且将插件.so文件放到bcs-scheduler相对路径./plugin/bin下面,然后增加启动参数"plugins": "xxxxx",上述例子应该填写ip-resources。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。