Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetes-dashboard patch improvements + helm-spray version mandatory update #9

Merged
merged 2 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions cmd/gokube/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ import (
)

const (
MONOCULAR_CHART_VERSION = "1.2.8"
MONOCULAR_APP_VERSION = "1.2.0"
NGINX_INGRESS_CHART_VERSION = "1.1.4"
NGINX_INGRESS_APP_VERSION = "0.23.0"
TPROXY_CHART_VERSION = "1.0.0"
NGINX_INGRESS_APP_VERSION = "0.23.0"
TPROXY_CHART_VERSION = "1.0.0"
DEFAULT_KUBERNETES_VERSION = "v1.10.13"
DEFAULT_MINIKUBE_VERSION = "v1.1.0"
)

var minikubeURL string
Expand Down Expand Up @@ -68,19 +67,27 @@ var ingressController bool
// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Short: "Initializes gokube. This command downloads dependencies: minikube + helm + kubectl + docker + monocular and creates the virtual machine (minikube)",
Long: "Initializes gokube. This command downloads dependencies: minikube + helm + kubectl + docker + monocular and creates the virtual machine (minikube)",
Short: "Initializes gokube. This command downloads dependencies: minikube + helm + kubectl + docker + stern and creates the virtual machine (minikube)",
Long: "Initializes gokube. This command downloads dependencies: minikube + helm + kubectl + docker + stern and creates the virtual machine (minikube)",
Run: initRun,
}

func init() {
var defaultKubernetesVersion = os.Getenv("KUBERNETES_VERSION")
if len(defaultKubernetesVersion) == 0 {
defaultKubernetesVersion = DEFAULT_KUBERNETES_VERSION
}
var defaultMinikubeVersion = os.Getenv("MINIKUBE_VERSION")
if len(defaultMinikubeVersion) == 0 {
defaultMinikubeVersion = DEFAULT_MINIKUBE_VERSION
}
initCmd.Flags().StringVarP(&minikubeURL, "minikube-url", "", "https://storage.googleapis.com/minikube/releases/%s/minikube-windows-amd64.exe", "The URL to download minikube")
initCmd.Flags().StringVarP(&minikubeVersion, "minikube-version", "", "v1.0.0", "The minikube version")
initCmd.Flags().StringVarP(&minikubeVersion, "minikube-version", "", defaultMinikubeVersion, "The minikube version")
initCmd.Flags().StringVarP(&dockerVersion, "docker-version", "", "18.09.0", "The docker version")
initCmd.Flags().StringVarP(&kubernetesVersion, "kubernetes-version", "", "v1.10.13", "The kubernetes version")
initCmd.Flags().StringVarP(&kubectlVersion, "kubectl-version", "", "v1.13.5", "The kubectl version")
initCmd.Flags().StringVarP(&kubernetesVersion, "kubernetes-version", "", defaultKubernetesVersion, "The kubernetes version")
initCmd.Flags().StringVarP(&kubectlVersion, "kubectl-version", "", "v1.13.6", "The kubectl version")
initCmd.Flags().StringVarP(&helmVersion, "helm-version", "", "v2.13.1", "The helm version")
initCmd.Flags().StringVarP(&helmSprayVersion, "helm-spray-version", "", "v3.3.0", "The helm version")
initCmd.Flags().StringVarP(&helmSprayVersion, "helm-spray-version", "", "v3.4.2", "The helm version")
initCmd.Flags().StringVarP(&sternVersion, "stern-version", "", "1.10.0", "The stern version")
initCmd.Flags().Int16VarP(&memory, "memory", "", int16(8192), "Amount of RAM allocated to the minikube VM in MB")
initCmd.Flags().Int16VarP(&cpus, "cpus", "", int16(4), "Number of CPUs allocated to the minikube VM")
Expand Down Expand Up @@ -160,7 +167,7 @@ func initRun(cmd *cobra.Command, args []string) {

// Create virtual machine (minikube)
minikube.Start(memory, cpus, disk, transparentProxy, httpProxy, httpsProxy, noProxy, insecureRegistry, kubernetesVersion, imageCache)
// Disbale notification for updates
// Disable notification for updates
minikube.ConfigSet("WantUpdateNotification", "false")
// Enable dashboard
minikube.ConfigSet("dashboard", "true")
Expand Down Expand Up @@ -224,8 +231,18 @@ func initRun(cmd *cobra.Command, args []string) {
}

// Patch kubernetes-dashboard to expose it on nodePort 30000
fmt.Println("Exposing kubernetes dashboard...")
kubectl.Patch("kube-system", "svc", "kubernetes-dashboard", "{\"spec\":{\"type\":\"NodePort\",\"ports\":[{\"port\":80,\"protocol\":\"TCP\",\"targetPort\":9090,\"nodePort\":30000}]}}")
fmt.Print("Exposing kubernetes dashboard...")
for n := 1; n < 12; n++ {
var dashboardService = kubectl.GetObject("kube-system", "svc", "kubernetes-dashboard")
if len(dashboardService) > 0 {
fmt.Println()
kubectl.Patch("kube-system", "svc", "kubernetes-dashboard", "{\"spec\":{\"type\":\"NodePort\",\"ports\":[{\"port\":80,\"protocol\":\"TCP\",\"targetPort\":9090,\"nodePort\":30000}]}}")
break
} else {
fmt.Print(".")
time.Sleep(10 * time.Second)
}
}

fmt.Println("\ngokube has been installed.")
if !imageCache {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gokube/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

const (
GOKUBE_VERSION = "1.6.0"
GOKUBE_VERSION = "1.6.2"
)

// versionCmd represents the version command
Expand Down
9 changes: 9 additions & 0 deletions pkg/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ const (
URL = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/windows/amd64/kubectl.exe"
)

// GetObject ...
func GetObject(namespace string, resourceType string, resourceName string) string {
output, err := exec.Command("kubectl", "--namespace", namespace, "get", resourceType, resourceName).Output()
if err != nil {
return ""
}
return string(output)
}

// ConfigUseContext ...
func ConfigUseContext(context string) {
cmd := exec.Command("kubectl", "config", "use-context", context)
Expand Down