37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
register.go 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
orangedeng 提交于 2018-11-29 10:35 . Deploy Cluster&Project Monitoring
package servicemonitor
import (
"context"
util "github.com/rancher/rancher/pkg/controllers/user/workload"
"github.com/rancher/types/apis/core/v1"
rmonitoringv1 "github.com/rancher/types/apis/monitoring.coreos.com/v1"
"github.com/rancher/types/config"
)
const (
creatorIDAnnotation = "field.cattle.io/creatorId"
metricsAnnotation = "field.cattle.io/workloadMetrics"
metricsServiceLabel = "cattle.io/metrics"
metricsServiceSuffix = "-metrics"
servicesAnnotation = "field.cattle.io/serviceIDs"
)
/*
The MetricsServiceController maintains the relation between workload, service monitor and service.
The service monitor will create services that point to workloads or pods with selector. The service monitor
owns those service and should delete with the object.
*/
type MetricsServiceController struct {
serviceLister v1.ServiceLister
services v1.ServiceInterface
smLister rmonitoringv1.ServiceMonitorLister
smClient rmonitoringv1.ServiceMonitorInterface
workloadLister util.CommonController
}
func Register(ctx context.Context, workload *config.UserOnlyContext) {
c := &MetricsServiceController{
serviceLister: workload.Core.Services("").Controller().Lister(),
services: workload.Core.Services(""),
smLister: workload.Monitoring.ServiceMonitors("").Controller().Lister(),
smClient: workload.Monitoring.ServiceMonitors(""),
workloadLister: util.NewWorkloadController(ctx, workload, nil),
}
util.NewWorkloadController(ctx, workload, c.createService)
workload.Core.Services("").Controller().AddHandler(ctx, "workloadMetrics", c.ensureService)
workload.Monitoring.ServiceMonitors("").Controller().AddHandler(ctx, "ensureServiceMetrics", c.ensureServiceMonitor)
workload.Monitoring.ServiceMonitors("").Controller().AddHandler(ctx, "workloadMetrics", c.syncServiceMonitor)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.0-rc12

搜索帮助

0d507c66 1850385 C8b1a773 1850385