diff --git a/cmd/provider/main.go b/cmd/provider/main.go index 5da54a73..58f3c350 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -29,6 +29,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/metrics" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/crossplane/crossplane-runtime/pkg/controller" @@ -63,6 +64,8 @@ func main() { leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").Envar("LEADER_ELECTION").Bool() maxReconcileRate = app.Flag("max-reconcile-rate", "The number of concurrent reconciliations that may be running at one time.").Default("100").Int() sanitizeSecrets = app.Flag("sanitize-secrets", "when enabled, redacts Secret data from Object status").Default("false").Envar("SANITIZE_SECRETS").Bool() + webhookPort = app.Flag("webhook-port", "The port the webhook listens on").Default("9443").Envar("WEBHOOK_PORT").Int() + metricsBindAddress = app.Flag("metrics-bind-address", "The address the metrics server listens on").Default(":8080").Envar("METRICS_BIND_ADDRESS").String() enableManagementPolicies = app.Flag("enable-management-policies", "Enable support for Management Policies.").Default("true").Envar("ENABLE_MANAGEMENT_POLICIES").Bool() enableWatches = app.Flag("enable-watches", "Enable support for watching resources.").Default("false").Envar("ENABLE_WATCHES").Bool() @@ -111,6 +114,10 @@ func main() { SyncPeriod: syncInterval, }, + Metrics: metricsserver.Options{ + BindAddress: *metricsBindAddress, + }, + // controller-runtime uses both ConfigMaps and Leases for leader // election by default. Leases expire after 15 seconds, with a // 10 second renewal deadline. We've observed leader loss due to @@ -125,6 +132,7 @@ func main() { RenewDeadline: func() *time.Duration { d := 50 * time.Second; return &d }(), WebhookServer: webhook.NewServer(webhook.Options{ CertDir: certDir, + Port: *webhookPort, }), }) kingpin.FatalIfError(err, "Cannot create controller manager")