37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
register.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 2019-06-12 13:38 . goimport linting changes
package servicemonitor
import (
"context"
util "github.com/rancher/rancher/pkg/controllers/user/workload"
v1 "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)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.7-rc2

搜索帮助