diff --git a/cmd/ccm/main.go b/cmd/ccm/main.go index d583ad1..fe12e17 100644 --- a/cmd/ccm/main.go +++ b/cmd/ccm/main.go @@ -106,12 +106,6 @@ func main() { flag.BoolVar(&enableSecretSynchronizer, "enable-secret-synchronizer", false, "Enable to automatically convert Secrets labelled with `kubelb.k8c.io/managed-by: kubelb` to Sync Secrets. This is used to sync secrets from tenants to the LB cluster in a controlled and secure way.") flag.BoolVar(&enableGatewayAPI, "enable-gateway-api", false, "Enable the Gateway APIs and controllers. By default Gateway API is disabled since without Gateway API CRDs installed the controller cannot start.") - if enableGatewayAPI { - utilruntime.Must(gwapiv1.Install(scheme)) - } - - disableGatewayAPI := !enableGatewayAPI - opts := zap.Options{ Development: false, TimeEncoder: zapcore.ISO8601TimeEncoder, @@ -119,6 +113,12 @@ func main() { opts.BindFlags(flag.CommandLine) flag.Parse() + if enableGatewayAPI { + utilruntime.Must(gwapiv1.Install(scheme)) + } + + disableGatewayAPI := !enableGatewayAPI + kubeconfig = flag.Lookup("kubeconfig").Value.(flag.Getter).Get().(string) ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) diff --git a/cmd/kubelb/main.go b/cmd/kubelb/main.go index 5a92768..37c15ad 100644 --- a/cmd/kubelb/main.go +++ b/cmd/kubelb/main.go @@ -81,12 +81,6 @@ func main() { flag.StringVar(&opt.kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") } - if opt.enableGatewayAPI { - utilruntime.Must(gwapiv1.Install(scheme)) - } - - disableGatewayAPI := !opt.enableGatewayAPI - if len(opt.namespace) == 0 { // Retrieve controller namespace ns, _ := os.LookupEnv("NAMESPACE") @@ -105,6 +99,12 @@ func main() { opts.BindFlags(flag.CommandLine) flag.Parse() + if opt.enableGatewayAPI { + utilruntime.Must(gwapiv1.Install(scheme)) + } + + disableGatewayAPI := !opt.enableGatewayAPI + ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme,