fix prometheusURL

Signed-off-by: f10atin9 <f10atin9@kubesphere.io>
This commit is contained in:
f10atin9
2022-02-24 16:01:37 +08:00
parent fdf5d73cb1
commit a810256f30
4 changed files with 22 additions and 22 deletions

View File

@@ -20,8 +20,6 @@ import (
"fmt"
"time"
"kubesphere.io/kubesphere/pkg/constants"
"github.com/kubesphere/pvc-autoresizer/runners"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/sets"
@@ -355,24 +353,25 @@ func addAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
}
// "pvc-autoresizer"
if cmOptions.IsControllerEnabled("pvc-autoresizer") {
if err := runners.SetupIndexer(mgr, false); err != nil {
return err
monitoringOptionsEnable := cmOptions.MonitoringOptions != nil && len(cmOptions.MonitoringOptions.Endpoint) != 0
if monitoringOptionsEnable {
if cmOptions.IsControllerEnabled("pvc-autoresizer") {
if err := runners.SetupIndexer(mgr, false); err != nil {
return err
}
promClient, err := runners.NewPrometheusClient(cmOptions.MonitoringOptions.Endpoint)
if err != nil {
return err
}
pvcAutoResizerController := runners.NewPVCAutoresizer(
promClient,
mgr.GetClient(),
ctrl.Log.WithName("pvc-autoresizer"),
1*time.Minute,
mgr.GetEventRecorderFor("pvc-autoresizer"),
)
addController(mgr, "pvcautoresizer", pvcAutoResizerController)
}
prometheusUrl := "http://" + constants.PrometheusSvcName + "." + constants.KubeSphereMonitoringNamespace + ":" + constants.PrometheusSvcPort
promClient, err := runners.NewPrometheusClient(prometheusUrl)
if err != nil {
return err
}
pvcAutoResizerController := runners.NewPVCAutoresizer(
promClient,
mgr.GetClient(),
ctrl.Log.WithName("pvc-autoresizer"),
1*time.Minute,
mgr.GetEventRecorderFor("pvc-autoresizer"),
)
addController(mgr, "pvcautoresizer", pvcAutoResizerController)
}
if cmOptions.IsControllerEnabled("workload-Restart") {

View File

@@ -22,6 +22,8 @@ import (
"strings"
"time"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
controllerconfig "kubesphere.io/kubesphere/pkg/apiserver/config"
"k8s.io/apimachinery/pkg/util/sets"
@@ -57,6 +59,7 @@ type KubeSphereControllerManagerOptions struct {
MultiClusterOptions *multicluster.Options
ServiceMeshOptions *servicemesh.Options
GatewayOptions *gateway.Options
MonitoringOptions *prometheus.Options
LeaderElect bool
LeaderElection *leaderelection.LeaderElectionConfig
WebhookCertDir string

View File

@@ -62,6 +62,7 @@ func NewControllerManagerCommand() *cobra.Command {
MultiClusterOptions: conf.MultiClusterOptions,
ServiceMeshOptions: conf.ServiceMeshOptions,
GatewayOptions: conf.GatewayOptions,
MonitoringOptions: conf.MonitoringOptions,
LeaderElection: s.LeaderElection,
LeaderElect: s.LeaderElect,
WebhookCertDir: s.WebhookCertDir,

View File

@@ -49,9 +49,6 @@ const (
UserNameHeader = "X-Token-Username"
PrometheusSvcName = "prometheus-k8s"
PrometheusSvcPort = "9090"
AuthenticationTag = "Authentication"
UserTag = "User"
GroupTag = "Group"