Skip to content

Commit

Permalink
make MetricsBindAddress and HealthProbeBindAddress configurable
Browse files Browse the repository at this point in the history
Signed-off-by: lihanbo <[email protected]>
  • Loading branch information
mrlihanbo committed Feb 9, 2022
1 parent b5493cc commit 9ad5cd9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
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
5 changes: 5 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,10 @@ 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.
MetricsBindAddress string
}

// NewOptions builds an empty options.
Expand Down Expand Up @@ -126,4 +130,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", "0", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8088, :8088)")
}
9 changes: 9 additions & 0 deletions cmd/webhook/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ type Options struct {
KubeAPIQPS float32
// KubeAPIBurst is the burst to allow while talking with karmada-apiserver.
KubeAPIBurst 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.
MetricsBindAddress string
// HealthProbeBindAddress is the TCP address that the controller should bind to
// for serving health probes
HealthProbeBindAddress string
}

// NewOptions builds an empty options.
Expand All @@ -50,4 +57,6 @@ func (o *Options) AddFlags(flags *pflag.FlagSet) {
flags.StringVar(&o.TLSMinVersion, "tls-min-version", defaultTLSMinVersion, "Minimum TLS version supported. Possible values: 1.0, 1.1, 1.2, 1.3.")
flags.Float32Var(&o.KubeAPIQPS, "kube-api-qps", 40.0, "QPS 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.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.StringVar(&o.MetricsBindAddress, "metrics-bind-address", "0", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8088, :8088)")
flags.StringVar(&o.HealthProbeBindAddress, "health-probe-bind-address", "0", "The TCP address that the controller should bind to for serving health probes(e.g. 127.0.0.1:8080, :8080)")
}
4 changes: 3 additions & 1 deletion cmd/webhook/app/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func Run(ctx context.Context, opts *options.Options) error {
CertDir: opts.CertDir,
TLSMinVersion: opts.TLSMinVersion,
},
LeaderElection: false,
LeaderElection: false,
MetricsBindAddress: opts.MetricsBindAddress,
HealthProbeBindAddress: opts.HealthProbeBindAddress,
})
if err != nil {
klog.Errorf("failed to build webhook server: %v", err)
Expand Down

0 comments on commit 9ad5cd9

Please sign in to comment.