diff --git a/cmd/agent/app/agent.go b/cmd/agent/app/agent.go index 477def79e07c..4c50bf1e9331 100644 --- a/cmd/agent/app/agent.go +++ b/cmd/agent/app/agent.go @@ -143,6 +143,7 @@ func run(ctx context.Context, karmadaConfig karmadactl.KarmadaConfig, opts *opti LeaderElectionID: fmt.Sprintf("karmada-agent-%s", opts.ClusterName), LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace, LeaderElectionResourceLock: opts.LeaderElection.ResourceLock, + MetricsBindAddress: opts.MetricsBindAddress, Controller: v1alpha1.ControllerConfigurationSpec{ GroupKindConcurrency: map[string]int{ workv1alpha1.SchemeGroupVersion.WithKind("Work").GroupKind().String(): opts.ConcurrentWorkSyncs, diff --git a/cmd/agent/app/options/options.go b/cmd/agent/app/options/options.go index cf303c2fdd3a..dc21a0731b3f 100644 --- a/cmd/agent/app/options/options.go +++ b/cmd/agent/app/options/options.go @@ -64,6 +64,11 @@ type Options struct { // ConcurrentWorkSyncs is the number of work objects that are // allowed to sync concurrently. ConcurrentWorkSyncs int + // MetricsBindAddress is the TCP address that the controller should bind to + // for serving prometheus metrics. + // It can be set to "0" to disable the metrics serving. + // Defaults to ":8080". + MetricsBindAddress string RateLimiterOpts ratelimiterflag.Options } @@ -111,5 +116,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) { fs.DurationVar(&o.ResyncPeriod.Duration, "resync-period", 0, "Base frequency the informers are resynced.") fs.IntVar(&o.ConcurrentClusterSyncs, "concurrent-cluster-syncs", 5, "The number of Clusters that are allowed to sync concurrently.") fs.IntVar(&o.ConcurrentWorkSyncs, "concurrent-work-syncs", 5, "The number of Works that are allowed to sync concurrently.") + fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8088, :8088)") o.RateLimiterOpts.AddFlags(fs) }