From 534b684a854484145fd28c5aa09c351ad820b3da Mon Sep 17 00:00:00 2001 From: Pedro Juarez Date: Mon, 12 Feb 2024 21:31:56 -0800 Subject: [PATCH] Controller DEV_MODE=on (#1923) by setting the env variable DEV_MODE=on MinIO Operator Controller expects to talk to local kubernetes API via kubectl proxy. Signed-off-by: pjuarezd --- pkg/controller/controller.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index f843e64950f..d5a12c13896 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -23,6 +23,8 @@ import ( "syscall" "time" + "github.com/minio/pkg/env" + "github.com/minio/operator/pkg" "k8s.io/client-go/tools/clientcmd" @@ -79,8 +81,21 @@ func StartOperator(kubeconfig string) { return } - // Look for incluster config by default - cfg, err := rest.InClusterConfig() + var cfg *rest.Config + var err error + + if token := env.Get("DEV_MODE", ""); token == "on" { + klog.Info("DEV_MODE present, running dev mode") + cfg = &rest.Config{ + Host: "http://localhost:8001", + TLSClientConfig: rest.TLSClientConfig{Insecure: true}, + APIPath: "/", + BearerToken: "", + } + } else { + // Look for incluster config by default + cfg, err = rest.InClusterConfig() + } // If config is passed as a flag use that instead if kubeconfig != "" { cfg, err = clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)