reconcile rulegroups to prometheusrules (#5081)
reconcile rulegroups Signed-off-by: junot <junotxiang@kubesphere.io>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
"sigs.k8s.io/kubefed/pkg/controller/util"
|
||||
|
||||
"kubesphere.io/kubesphere/cmd/controller-manager/app/options"
|
||||
"kubesphere.io/kubesphere/pkg/controller/alerting"
|
||||
"kubesphere.io/kubesphere/pkg/controller/application"
|
||||
"kubesphere.io/kubesphere/pkg/controller/helm"
|
||||
"kubesphere.io/kubesphere/pkg/controller/namespace"
|
||||
@@ -540,6 +541,26 @@ func addAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
|
||||
}
|
||||
}
|
||||
|
||||
// controllers for alerting
|
||||
alertingOptionsEnable := cmOptions.AlertingOptions != nil && (cmOptions.AlertingOptions.PrometheusEndpoint != "" || cmOptions.AlertingOptions.ThanosRulerEndpoint != "")
|
||||
if alertingOptionsEnable {
|
||||
// "rulegroup" controller
|
||||
if cmOptions.IsControllerEnabled("rulegroup") {
|
||||
rulegroupReconciler := &alerting.RuleGroupReconciler{}
|
||||
addControllerWithSetup(mgr, "rulegroup", rulegroupReconciler)
|
||||
}
|
||||
// "clusterrulegroup" controller
|
||||
if cmOptions.IsControllerEnabled("clusterrulegroup") {
|
||||
clusterrulegroupReconciler := &alerting.ClusterRuleGroupReconciler{}
|
||||
addControllerWithSetup(mgr, "clusterrulegroup", clusterrulegroupReconciler)
|
||||
}
|
||||
// "globalrulegroup" controller
|
||||
if cmOptions.IsControllerEnabled("globalrulegroup") {
|
||||
globalrulegroupReconciler := &alerting.GlobalRuleGroupReconciler{}
|
||||
addControllerWithSetup(mgr, "globalrulegroup", globalrulegroupReconciler)
|
||||
}
|
||||
}
|
||||
|
||||
// log all controllers process result
|
||||
for _, name := range allControllers {
|
||||
if cmOptions.IsControllerEnabled(name) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/alerting"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
|
||||
|
||||
controllerconfig "kubesphere.io/kubesphere/pkg/apiserver/config"
|
||||
@@ -60,6 +61,7 @@ type KubeSphereControllerManagerOptions struct {
|
||||
ServiceMeshOptions *servicemesh.Options
|
||||
GatewayOptions *gateway.Options
|
||||
MonitoringOptions *prometheus.Options
|
||||
AlertingOptions *alerting.Options
|
||||
LeaderElect bool
|
||||
LeaderElection *leaderelection.LeaderElectionConfig
|
||||
WebhookCertDir string
|
||||
@@ -99,6 +101,7 @@ func NewKubeSphereControllerManagerOptions() *KubeSphereControllerManagerOptions
|
||||
ServiceMeshOptions: servicemesh.NewServiceMeshOptions(),
|
||||
AuthenticationOptions: authentication.NewOptions(),
|
||||
GatewayOptions: gateway.NewGatewayOptions(),
|
||||
AlertingOptions: alerting.NewAlertingOptions(),
|
||||
LeaderElection: &leaderelection.LeaderElectionConfig{
|
||||
LeaseDuration: 30 * time.Second,
|
||||
RenewDeadline: 15 * time.Second,
|
||||
@@ -126,6 +129,7 @@ func (s *KubeSphereControllerManagerOptions) Flags(allControllerNameSelectors []
|
||||
s.MultiClusterOptions.AddFlags(fss.FlagSet("multicluster"), s.MultiClusterOptions)
|
||||
s.ServiceMeshOptions.AddFlags(fss.FlagSet("servicemesh"), s.ServiceMeshOptions)
|
||||
s.GatewayOptions.AddFlags(fss.FlagSet("gateway"), s.GatewayOptions)
|
||||
s.AlertingOptions.AddFlags(fss.FlagSet("alerting"), s.AlertingOptions)
|
||||
fs := fss.FlagSet("leaderelection")
|
||||
s.bindLeaderElectionFlags(s.LeaderElection, fs)
|
||||
|
||||
@@ -171,6 +175,7 @@ func (o *KubeSphereControllerManagerOptions) Validate(allControllerNameSelectors
|
||||
errs = append(errs, o.NetworkOptions.Validate()...)
|
||||
errs = append(errs, o.LdapOptions.Validate()...)
|
||||
errs = append(errs, o.MultiClusterOptions.Validate()...)
|
||||
errs = append(errs, o.AlertingOptions.Validate()...)
|
||||
|
||||
// genetic option: application-selector
|
||||
if len(o.ApplicationSelector) != 0 {
|
||||
|
||||
@@ -67,6 +67,7 @@ func NewControllerManagerCommand() *cobra.Command {
|
||||
ServiceMeshOptions: conf.ServiceMeshOptions,
|
||||
GatewayOptions: conf.GatewayOptions,
|
||||
MonitoringOptions: conf.MonitoringOptions,
|
||||
AlertingOptions: conf.AlertingOptions,
|
||||
LeaderElection: s.LeaderElection,
|
||||
LeaderElect: s.LeaderElect,
|
||||
WebhookCertDir: s.WebhookCertDir,
|
||||
|
||||
Reference in New Issue
Block a user