lib/sct/commands/cluster.rb in sct-0.1.7 vs lib/sct/commands/cluster.rb in sct-0.1.8
- old
+ new
@@ -3,38 +3,46 @@
module Sct
class ClusterCommand
IS_PUBLIC_COMMAND = true
- SYNTAX = 'sct cluster up | sct cluster down'
- SUMMARY = 'Starts or stops the minikube cluster'
- EXAMPLE = 'sct cluster up | sct cluster down'
- EXAMPLE_DESCRIPTION = 'Starts or stops the spend cloud cluster'
- DESCRIPTION = "Sct cluster allows you to start and stop the Spend Cloud minikube cluster"
+ SYNTAX = 'sct cluster up | sct cluster down | sct cluster update-config'
+ SUMMARY = 'Starts/stops or updates the config of the minikube cluster'
+ EXAMPLE = 'sct cluster up | sct cluster down | sct cluster update-config'
+ EXAMPLE_DESCRIPTION = 'Starts/stops or updates the config of the minikube cluster'
+ DESCRIPTION = "Sct cluster allows you to start, stop or update the config of the Spend Cloud minikube cluster"
OPTIONS = []
def execute(args, options)
return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
- if `uname -a`.match?("Microsoft")
- minikube = "minikube.exe"
- else
- minikube = "minikube"
- end
-
case args[0]
when "up"
- system("#{minikube} start")
- system("#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
- system("kubectl config use-context minikube")
- system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')")
- system("sudo sct hostfile")
- puts "\nāļø You can now visit your environment at š https://spend-cloud.spend.cloud.local š"
+ system("minikube start")
+ system("minikube ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
+ system("sct cluster update-config")
+ system("kubectl config use-context minikube")
+ system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')")
+ system("sudo sct hostfile")
+ puts "\nāļø You can now visit your environment at š https://spend-cloud.spend.cloud.local š"
when "down"
- system("#{minikube} stop")
+ system("minikube stop")
+ when "update-config"
+ return puts "Skipping minikube config ( only needed for windows )".yellow unless Sct::Config.operatingSystem == Sct::Config::WINDOWS
+
+ windows_home_path = Sct::Config.getTrueHomePath
+ kube_file_path = windows_home_path+"/.kube/config"
+
+ if !File.exists?(kube_file_path)
+ return puts "#{kube_file_path} doesn't exist".red
+ end
+
+ system("sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config")
+
+ return puts "Windows minikube config copied to ~/.kube/minikube-config".green
else
- puts "Unknown or missing argument. Please run 'sct cluster up' or 'sct cluster down'"
+ puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red
end
end
implements CommandInterface