Skip to content

Commit

Permalink
make metrics server port configurable (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhelfand authored Oct 21, 2021
1 parent 69c59a6 commit acb8351
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ const (
)

type Options struct {
Concurrency int
Namespace string
EnablePprof bool
APIRequestTimeout time.Duration
PackagingGloablNS string
Concurrency int
Namespace string
EnablePprof bool
APIRequestTimeout time.Duration
PackagingGloablNS string
MetricsBindAddress string
}

// Based on https://github.com/kubernetes-sigs/controller-runtime/blob/8f633b179e1c704a6e40440b528252f147a3362a/examples/builtins/main.go
Expand All @@ -53,7 +54,8 @@ func Run(opts Options, runLog logr.Logger) error {
restConfig.Timeout = opts.APIRequestTimeout
}

mgr, err := manager.New(restConfig, manager.Options{Namespace: opts.Namespace, Scheme: kcconfig.Scheme})
mgr, err := manager.New(restConfig, manager.Options{Namespace: opts.Namespace,
Scheme: kcconfig.Scheme, MetricsBindAddress: opts.MetricsBindAddress})
if err != nil {
return fmt.Errorf("Setting up overall controller manager: %s", err)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func main() {
flag.IntVar(&ctrlOpts.Concurrency, "concurrency", 10, "Max concurrent reconciles")
flag.StringVar(&ctrlOpts.Namespace, "namespace", "", "Namespace to watch")
flag.StringVar(&ctrlOpts.PackagingGloablNS, "packaging-global-namespace", "", "The namespace used for global packaging resources")
flag.StringVar(&ctrlOpts.MetricsBindAddress, "metrics-bind-address", ":8080", "Address for metrics server. If 0, then metrics server doesnt listen on any port.")
flag.BoolVar(&ctrlOpts.EnablePprof, "dangerous-enable-pprof", false, "If set to true, enable pprof on "+controller.PprofListenAddr)
flag.DurationVar(&ctrlOpts.APIRequestTimeout, "api-request-timeout", time.Duration(0), "HTTP timeout for Kubernetes API requests")
flag.BoolVar(&runController, controllerinit.InternalControllerFlag, false, "[Internal] run the controller code")
Expand Down

0 comments on commit acb8351

Please sign in to comment.