Skip to content

Commit 534b684

Browse files
authored
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 <pjuarezd@users.noreply.github.com>
1 parent acd94bf commit 534b684

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pkg/controller/controller.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"syscall"
2424
"time"
2525

26+
"github.com/minio/pkg/env"
27+
2628
"github.com/minio/operator/pkg"
2729

2830
"k8s.io/client-go/tools/clientcmd"
@@ -79,8 +81,21 @@ func StartOperator(kubeconfig string) {
7981
return
8082
}
8183

82-
// Look for incluster config by default
83-
cfg, err := rest.InClusterConfig()
84+
var cfg *rest.Config
85+
var err error
86+
87+
if token := env.Get("DEV_MODE", ""); token == "on" {
88+
klog.Info("DEV_MODE present, running dev mode")
89+
cfg = &rest.Config{
90+
Host: "http://localhost:8001",
91+
TLSClientConfig: rest.TLSClientConfig{Insecure: true},
92+
APIPath: "/",
93+
BearerToken: "",
94+
}
95+
} else {
96+
// Look for incluster config by default
97+
cfg, err = rest.InClusterConfig()
98+
}
8499
// If config is passed as a flag use that instead
85100
if kubeconfig != "" {
86101
cfg, err = clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)

0 commit comments

Comments
 (0)