Skip to content

Commit

Permalink
Controller DEV_MODE=on (minio#1923)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pjuarezd authored Feb 13, 2024
1 parent acd94bf commit 534b684
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"syscall"
"time"

"github.com/minio/pkg/env"

"github.com/minio/operator/pkg"

"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 534b684

Please sign in to comment.