diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index f9dc8060a66d..0ca4d4248bb4 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -23,6 +23,7 @@ import ( "os" "time" + "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -64,29 +65,33 @@ var ( webhookPort int ) -func main() { - flag.StringVar(&metricsAddr, "metrics-addr", ":8080", +// InitFlags initializes the flags. +func InitFlags(fs *pflag.FlagSet) { + fs.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") - flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, + fs.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") - flag.StringVar(&watchNamespace, "namespace", "", + fs.StringVar(&watchNamespace, "namespace", "", "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") - flag.StringVar(&profilerAddress, "profiler-address", "", + fs.StringVar(&profilerAddress, "profiler-address", "", "Bind address to expose the pprof profiler (e.g. localhost:6060)") - flag.IntVar(&kubeadmControlPlaneConcurrency, "kubeadmcontrolplane-concurrency", 10, + fs.IntVar(&kubeadmControlPlaneConcurrency, "kubeadmcontrolplane-concurrency", 10, "Number of kubeadm control planes to process simultaneously") - flag.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, + fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, "The minimum interval at which watched resources are reconciled (e.g. 15m)") - flag.IntVar(&webhookPort, "webhook-port", 0, + fs.IntVar(&webhookPort, "webhook-port", 0, "Webhook Server port, disabled by default. When enabled, the manager will only work as webhook server, no reconcilers are installed.") - - flag.Parse() +} +func main() { + InitFlags(pflag.CommandLine) + pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + pflag.Parse() ctrl.SetLogger(klogr.New())