Skip to content

Commit

Permalink
create cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Pröschel committed Mar 9, 2021
1 parent 8e80af6 commit 2b75ed5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
5 changes: 4 additions & 1 deletion infrastructure/cli/pkg/providers/minikube/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ go_library(
srcs = ["minikube.go"],
importpath = "cli/pkg/providers/minikube",
visibility = ["//visibility:public"],
deps = ["//infrastructure/cli/pkg/kube"],
deps = [
"//infrastructure/cli/pkg/kube",
"@io_k8s_client_go//util/homedir:go_default_library",
],
)
45 changes: 34 additions & 11 deletions infrastructure/cli/pkg/providers/minikube/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,50 @@ package minikube
import (
"cli/pkg/kube"
"fmt"
"os"
"k8s.io/client-go/util/homedir"
"os/exec"
"path/filepath"
)

const minikube = "minikube"
const (
minikube = "minikube"
profile = "airy-core"
)

type Minikube struct {
}

func (m *Minikube) Provision() (kube.KubeCtx, error) {
mustBeInstalled()
fmt.Println("minikube provider not yet implemented")
os.Exit(1)
return kube.KubeCtx{}, nil
if err := checkInstallation(); err != nil {
return kube.KubeCtx{}, err
}

if err := startCluster(); err != nil {
return kube.KubeCtx{}, err
}

homeDir := homedir.HomeDir()
if homeDir == "" {
return kube.KubeCtx{}, fmt.Errorf("could not find the kubeconfig")
}

return kube.New(filepath.Join(homeDir, ".kube", "config"), profile), nil
}

func mustBeInstalled() {
func checkInstallation() error {
_, err := exec.LookPath(minikube)
if err != nil {
panic("could not find minikube installation. Please install Minikube from here https://github.com/kubernetes/minikube/releases")
}
return err
}

func startCluster() error {
return runMinikube("start", "--cpus=4", "--memory=7168")
}

func startCluster
func runMinikube(args ...string) error {
defaultArgs := []string{"--profile="+profile}
cmd := exec.Command("minikube", append(defaultArgs, args...)...)
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("running Minikube failed with err: %v\n%v", err, string(out))
}
return nil
}

0 comments on commit 2b75ed5

Please sign in to comment.