cluster/lib/cluster/runner.rb in sct-0.1.31 vs cluster/lib/cluster/runner.rb in sct-0.1.33
- old
+ new
@@ -17,10 +17,13 @@
wait_for_gcr_secret
run_command "kubectl apply -f ~/development/spend-cloud/k8s/ingress.yml"
wait_for_ingress_ip
run_command "kubectl apply -f ~/development/spend-cloud/k8s/dependencies.yml"
wait_for_pods
+ create_keycloak_database_user
+ run_command "kubectl apply -f ~/development/spend-cloud/k8s/keycloak-server.yml"
+ wait_for_pods
run_command "kubectl apply -f ~/development/spend-cloud/k8s/"
end
post_start
end
@@ -87,23 +90,27 @@
return true
end
def start_cluster
if SctCore::Helper.operatingSystem == SctCore::Helper::MAC_OS
- run_command "minikube start --driver=docker --cpus=$(sysctl -n hw.ncpu) --memory=8G"
+ run_command "minikube start --driver=hyperkit --vm=true --cpus=$(sysctl -n hw.ncpu) --memory=8G"
else
run_command "minikube start --driver=docker --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=3G"
end
update_config
end
def post_start
wait_for_pods
copy_proactive_accounts_file
- run_command "sudo sct hostfile"
+ if SctCore::Helper.operatingSystem != SctCore::Helper::WINDOWS
+ UI.success("\nAdding SSH tunnel to port 443!")
+ run_command "sudo ssh -f -N -i $(minikube ssh-key) docker@$(minikube ip) -L 443:127.0.0.1:443"
+ end
+# run_command "sudo sct hostfile"
run_command "minikube tunnel &", { out: "/dev/null", err: "/dev/null" } if SctCore::Helper::is_windows? # leave this running detached forever in the background
- UI.success("\nāļø You can visit your environment at š https://spend-cloud.spend.cloud.local š")
+ UI.success("\nāļø You can visit your environment at š https://spend-cloud.dev.spend.cloud š")
end
def enable_addons
enable_addon "registry-creds"
enable_addon "ingress"
@@ -306,9 +313,26 @@
command = "kubectl cp #{src_path} #{pod_id}:/data/proactive_accounts.ini -c #{container_name}"
run_command command
end
UI.success("ProActive accounts file is available")
+ end
+
+ def create_keycloak_database_user
+ container_name = "mysql-service"
+ pod_id = pods().select {|pod| pod[:name].start_with?(container_name)}.first[:name]
+
+ UI.important("Creating keycloak user")
+ create_user = "CREATE USER 'keycloak'@'%' IDENTIFIED BY 'keycloak';"
+ run_command "kubectl exec #{pod_id} -- mysql -e '#{create_user}' >> /dev/null"
+
+ UI.important("Creating keycloak database")
+ create_database = "CREATE DATABASE keycloak CHARACTER SET utf8 COLLATE UTF8_UNICODE_CI;"
+ run_command "kubectl exec #{pod_id} -- mysql -e '#{create_database}' >> /dev/null"
+
+ UI.important("Granting privileges to keycloak user")
+ grant_privileges = "GRANT ALL PRIVILEGES ON keycloak.* TO 'keycloak'@'%';"
+ run_command "kubectl exec #{pod_id} -- mysql -e '#{grant_privileges}' >> /dev/null"
end
def run_command command, options = {}
if ! system command, options
raise command.red