diff --git a/cmd/catalogd/main.go b/cmd/catalogd/main.go index 64efd83edc..e6e4758b2e 100644 --- a/cmd/catalogd/main.go +++ b/cmd/catalogd/main.go @@ -37,8 +37,6 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/metadata" _ "k8s.io/client-go/plugin/pkg/client/auth" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" @@ -97,7 +95,6 @@ type config struct { webhookPort int pullCasDir string globalPullSecret string - kubeconfig string // Generated config globalPullSecretKey *k8stypes.NamespacedName } @@ -139,7 +136,6 @@ func init() { flags.IntVar(&cfg.webhookPort, "webhook-server-port", 9443, "Webhook server port") flags.StringVar(&cfg.pullCasDir, "pull-cas-dir", "", "The directory of TLS certificate authorities to use for verifying HTTPS connections to image registries.") flags.StringVar(&cfg.globalPullSecret, "global-pull-secret", "", "Global pull secret (/)") - flags.StringVar(&cfg.kubeconfig, "kubeconfig", "", "Path to kubeconfig file for API server access. Uses in-cluster config if empty.") // adds version subcommand catalogdCmd.AddCommand(versionCommand) @@ -277,20 +273,8 @@ func run(ctx context.Context) error { return err } - // Create manager with kubeconfig support for non-default kubeconfig - var restConfig *rest.Config - if cfg.kubeconfig != "" { - setupLog.Info("loading kubeconfig from file", "path", cfg.kubeconfig) - restConfig, err = clientcmd.BuildConfigFromFlags("", cfg.kubeconfig) - if err != nil { - setupLog.Error(err, "unable to load kubeconfig") - return err - } - } else { - restConfig = ctrl.GetConfigOrDie() - } - - mgr, err := ctrl.NewManager(restConfig, ctrl.Options{ + // Create manager + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, Metrics: metricsServerOptions, PprofBindAddress: cfg.pprofAddr, diff --git a/cmd/operator-controller/main.go b/cmd/operator-controller/main.go index 5c953d05cc..aeca882f01 100644 --- a/cmd/operator-controller/main.go +++ b/cmd/operator-controller/main.go @@ -41,8 +41,6 @@ import ( "k8s.io/client-go/discovery/cached/memory" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" _ "k8s.io/client-go/plugin/pkg/client/auth" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" "k8s.io/utils/ptr" "pkg.package-operator.run/boxcutter/managedcache" @@ -107,7 +105,6 @@ type config struct { catalogdCasDir string pullCasDir string globalPullSecret string - kubeconfig string } type reconcilerConfigurator interface { @@ -187,7 +184,6 @@ func init() { flags.StringVar(&cfg.cachePath, "cache-path", "/var/cache", "The local directory path used for filesystem based caching") flags.StringVar(&cfg.systemNamespace, "system-namespace", "", "Configures the namespace that gets used to deploy system resources.") flags.StringVar(&cfg.globalPullSecret, "global-pull-secret", "", "The / of the global pull secret that is going to be used to pull bundle images.") - flags.StringVar(&cfg.kubeconfig, "kubeconfig", "", "Path to kubeconfig file for API server access. Uses in-cluster config if empty.") //adds version sub command operatorControllerCmd.AddCommand(versionCommand) @@ -329,18 +325,7 @@ func run() error { "Metrics will not be served since the TLS certificate and key file are not provided.") } - // Load REST config with kubeconfig support for non-default kubeconfig - var restConfig *rest.Config - if cfg.kubeconfig != "" { - setupLog.Info("loading kubeconfig from file", "path", cfg.kubeconfig) - restConfig, err = clientcmd.BuildConfigFromFlags("", cfg.kubeconfig) - if err != nil { - setupLog.Error(err, "unable to load kubeconfig") - return err - } - } else { - restConfig = ctrl.GetConfigOrDie() - } + restConfig := ctrl.GetConfigOrDie() mgr, err := ctrl.NewManager(restConfig, ctrl.Options{ Scheme: scheme.Scheme, Metrics: metricsServerOptions,