Skip to content

Commit

Permalink
Merge pull request #1341 from pigletfly/add-metrics-addr
Browse files Browse the repository at this point in the history
Introduce `--metrics-bind-address` flag to `karmada-controller-manager`
  • Loading branch information
karmada-bot authored Feb 10, 2022
2 parents 94b4f93 + 98ae691 commit ca29972
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func Run(ctx context.Context, opts *options.Options) error {
LeaderElectionResourceLock: opts.LeaderElection.ResourceLock,
HealthProbeBindAddress: net.JoinHostPort(opts.BindAddress, strconv.Itoa(opts.SecurePort)),
LivenessEndpointName: "/healthz",
MetricsBindAddress: opts.MetricsBindAddress,
})
if err != nil {
klog.Errorf("failed to build controller manager: %v", err)
Expand Down
6 changes: 6 additions & 0 deletions cmd/controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ type Options struct {
// ResyncPeriod is the base frequency the informers are resynced.
// Defaults to 0, which means the created informer will never do resyncs.
ResyncPeriod metav1.Duration
// 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
}

// NewOptions builds an empty options.
Expand Down Expand Up @@ -126,4 +131,5 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers []string) {
flags.IntVar(&o.KubeAPIBurst, "kube-api-burst", 60, "Burst to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
flags.DurationVar(&o.ClusterCacheSyncTimeout.Duration, "cluster-cache-sync-timeout", util.CacheSyncTimeout, "Timeout period waiting for cluster cache to sync.")
flags.DurationVar(&o.ResyncPeriod.Duration, "resync-period", 0, "Base frequency the informers are resynced.")
flags.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
}

0 comments on commit ca29972

Please sign in to comment.