代码拉取完成,页面将自动刷新
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。