Update BM deploy
- Use bootstrapv2
- Update templates according to latest release
PROD-37312
Change-Id: Ib4e60febbd8a4c04b5061928b25bdaaeee701028
diff --git a/bm_mcc_mosk/seed/do_deploy_child.sh b/bm_mcc_mosk/seed/do_deploy_child.sh
new file mode 100644
index 0000000..6229555
--- /dev/null
+++ b/bm_mcc_mosk/seed/do_deploy_child.sh
@@ -0,0 +1,13 @@
+set -e
+while [ ! -d /root/bm_mcc_mosk/child/cluster ] ; do echo 'no child templates!' ; sleep 4 ; done
+export KUBECONFIG=/root/kubeconfig
+/root/kaas-bootstrap/bin/kubectl apply -f /root/bm_mcc_mosk/child/cluster/project.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/ssh_pubkeys.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/cluster.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/baremetalhosts.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/baremetalhostprofiles.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/subnets.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/l2_templates.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/metallbconfig.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/machines.yaml
+sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/kaascephcluster.yaml
diff --git a/bm_mcc_mosk/seed/do_deploy_mcc_mgmt.sh b/bm_mcc_mosk/seed/do_deploy_mcc_mgmt.sh
new file mode 100644
index 0000000..b14994c
--- /dev/null
+++ b/bm_mcc_mosk/seed/do_deploy_mcc_mgmt.sh
@@ -0,0 +1,77 @@
+set -e
+source /root/bm_mcc_mosk/seed/env_vars.sh
+
+pushd /root/
+ wget https://binary.mirantis.com/releases/get_container_cloud.sh
+ chmod 0755 get_container_cloud.sh
+ ./get_container_cloud.sh
+ cp /root/mirantis.lic kaas-bootstrap/
+popd
+
+/root/kaas-bootstrap/bootstrap.sh bootstrapv2
+
+
+export KUBECONFIG=/root/.kube/kind-config-clusterapi
+pushd /root/bm_mcc_mosk/kaas-mgmt
+ /root/kaas-bootstrap/bin/kubectl apply -f bootstrapregion.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f serviceuser.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f cluster.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f baremetalhostprofiles.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f ipam-objects.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f baremetalhosts.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f metallbconfig.yaml && sleep 2
+ /root/kaas-bootstrap/bin/kubectl apply -f machines.yaml && sleep 2
+popd
+
+retry=60
+interval=60
+
+counter=0
+while (( counter++ < retry )) ; do
+ sleep $interval
+ avail_count=$(/root/kaas-bootstrap/bin/kubectl get bmh -o go-template='{{- range .items -}} {{.status.provisioning.state}}{{"\n"}} {{- end -}}' | (grep -c available || /bin/true))
+ echo "loop=${counter}, available state=${avail_count}"
+ if (( avail_count == 3 )); then
+ break
+ fi
+done
+if (( counter > retry )) ; then
+ echo "Not all nodes are available after timeout"
+ exit 1
+fi
+
+counter=0
+while (( counter++ < retry )) ; do
+ sleep $interval
+ status=$(/root/kaas-bootstrap/bin/kubectl get bootstrapregions -o go-template='{{(index .items 0).status.ready}}{{"\n"}}')
+ echo "loop=${counter}, status=${status}"
+ if [[ "$status" == "true" ]]; then
+ break
+ fi
+done
+if (( counter > retry )) ; then
+ echo "BootstrapRegion timed out"
+ exit 1
+fi
+
+/root/kaas-bootstrap/container-cloud bootstrap approve all
+
+counter=0
+retry=90
+while (( counter++ < retry )) ; do
+ sleep $interval
+ status=$(/root/kaas-bootstrap/bin/kubectl get cluster kaas-mgmt -o go-template='{{.status.providerStatus.ready}}{{"\n"}}')
+ echo "loop=${counter}, status=${status}"
+ if [[ "$status" == "true" ]]; then
+ break
+ fi
+done
+if (( counter > retry )) ; then
+ echo "MGMT Cluster deployment timed out"
+ exit 1
+fi
+cd
+/root/kaas-bootstrap/container-cloud get cluster-kubeconfig --cluster-name kaas-mgmt --kubeconfig-output /root/kubeconfig
+echo r00tme | /root/kaas-bootstrap/container-cloud bootstrap user add --username root --roles global-admin,management-admin,reader,writer,operator --kubeconfig kubeconfig --password-stdin
+/root/kaas-bootstrap/bin/kind delete cluster -n clusterapi
+unset KUBECONFIG
diff --git a/bm_mcc_mosk/seed/env_vars.sh b/bm_mcc_mosk/seed/env_vars.sh
new file mode 100644
index 0000000..6252ad9
--- /dev/null
+++ b/bm_mcc_mosk/seed/env_vars.sh
@@ -0,0 +1,7 @@
+export KAAS_BM_ENABLED="true"
+export KAAS_BM_PXE_IP="172.16.180.5"
+export KAAS_BM_PXE_MASK="23"
+export KAAS_BM_PXE_BRIDGE="br0"
+export CLUSTER_NAME=kaas-mgmt
+export OUT_DIR=/root/bm_mcc_mosk/kaas-mgmt/
+#export KAAS_BOOTSTRAP_INFINITE_TIMEOUT=true
\ No newline at end of file
diff --git a/bm_mcc_mosk/seed/get_child_kubeconfig.sh b/bm_mcc_mosk/seed/get_child_kubeconfig.sh
new file mode 100644
index 0000000..23565e7
--- /dev/null
+++ b/bm_mcc_mosk/seed/get_child_kubeconfig.sh
@@ -0,0 +1,2 @@
+/root/kaas-bootstrap/bin/kubectl --kubeconfig /root/kubeconfig -n mosk get secrets mosk-kubeconfig -o jsonpath='{.data.admin\.conf}' | base64 -d | sed 's/:5443/:443/g' > /root/child.kubeconfig
+export KUBECONFIG=/root/child.kubeconfig
\ No newline at end of file