Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

METAL-834: Add --metrics-addr argument to controller #110

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func setupChecks(mgr ctrl.Manager) error {
return nil
}

func runController(watchNamespace string, imageServer imagehandler.ImageHandler, envInputs *env.EnvInputs) error {
func runController(watchNamespace string, imageServer imagehandler.ImageHandler, envInputs *env.EnvInputs, metricsBindAddr string) error {
excludeInfraEnv, err := labels.NewRequirement(infraEnvLabel, selection.DoesNotExist, nil)
if err != nil {
setupLog.Error(err, "cannot create an infraenv label filter")
Expand All @@ -89,10 +89,11 @@ func runController(watchNamespace string, imageServer imagehandler.ImageHandler,
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Port: 0, // Add flag with default of 9443 when adding webhooks
Namespace: watchNamespace,
Cache: cacheOptions,
Scheme: scheme,
Port: 0, // Add flag with default of 9443 when adding webhooks
Namespace: watchNamespace,
Cache: cacheOptions,
MetricsBindAddress: metricsBindAddr,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this lgtm, Just wondering if we should add TLS Config like we have in BMO and CBO...

})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down Expand Up @@ -123,6 +124,7 @@ func runController(watchNamespace string, imageServer imagehandler.ImageHandler,

func main() {
var watchNamespace string
var metricsBindAddr string
var devLogging bool
var imagesBindAddr string
var imagesPublishAddr string
Expand All @@ -133,6 +135,8 @@ func main() {
// namespace.
flag.StringVar(&watchNamespace, "namespace", os.Getenv("WATCH_NAMESPACE"),
"Namespace that the controller watches to reconcile preprovisioningimage resources.")
flag.StringVar(&metricsBindAddr, "metrics-addr", "",
"The address the metric endpoint binds to.")
flag.StringVar(&imagesBindAddr, "images-bind-addr", ":8084",
"The address the images endpoint binds to.")
flag.StringVar(&imagesPublishAddr, "images-publish-addr", "http://127.0.0.1:8084",
Expand Down Expand Up @@ -172,7 +176,7 @@ func main() {
}
}()

if err := runController(watchNamespace, imageServer, envInputs); err != nil {
if err := runController(watchNamespace, imageServer, envInputs, metricsBindAddr); err != nil {
setupLog.Error(err, "problem running controller")
os.Exit(1)
}
Expand Down