Skip to content

Commit

Permalink
Add metrics-addr to expose prometheus metrics
Browse files Browse the repository at this point in the history
Signed-off-by: pigletfly <[email protected]>
  • Loading branch information
pigletfly committed Feb 7, 2022
1 parent 2c35bff commit ad73caf
Show file tree
Hide file tree
Showing 2 changed files with 4 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.MetricsAddr,
})
if err != nil {
klog.Errorf("failed to build controller manager: %v", err)
Expand Down
3 changes: 3 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,8 @@ 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
// MetricsAddr is address the metric endpoint binds to
MetricsAddr string
}

// NewOptions builds an empty options.
Expand Down Expand Up @@ -126,4 +128,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.MetricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
}

0 comments on commit ad73caf

Please sign in to comment.