diff --git a/cicd/common.sh b/cicd/common.sh index dfd3e147a..43cdbe208 100644 --- a/cicd/common.sh +++ b/cicd/common.sh @@ -552,37 +552,3 @@ function add_route() { echo "$1: ip route add $2 via $3 proto static" $hexec $1 ip route add $2 via $3 proto static } - -function wait_cluster_ready { - Res=$(sudo kubectl get pods -A | - while IFS= read -r line; do - if [[ "$line" != *"Running"* && "$line" != *"READY"* ]]; then - echo "not ready" - return - fi - done) - if [[ $Res == *"not ready"* ]]; then - return 1 - fi - return 0 -} - -function wait_cluster_ready_full { - i=1 - nr=0 - for ((;;)) do - wait_cluster_ready - nr=$? - if [[ $nr == 0 ]]; then - echo "Cluster is ready" - break - fi - i=$(( $i + 1 )) - if [[ $i -ge 40 ]]; then - echo "Cluster is not ready.Giving up" - exit 1 - fi - echo "Cluster is not ready...." - sleep 10 - done -} diff --git a/cicd/k0s-weave/config.sh b/cicd/k0s-weave/config.sh index 0379cc7ab..46d8bf7e3 100755 --- a/cicd/k0s-weave/config.sh +++ b/cicd/k0s-weave/config.sh @@ -2,6 +2,41 @@ source ../common.sh + +function wait_k0s_cluster_ready { + Res=$(sudo k0s kubectl get pods -A | + while IFS= read -r line; do + if [[ "$line" != *"Running"* && "$line" != *"READY"* ]]; then + echo "not ready" + return + fi + done) + if [[ $Res == *"not ready"* ]]; then + return 1 + fi + return 0 +} + +function wait_k0s_cluster_ready_full { + i=1 + nr=0 + for ((;;)) do + wait_k0s_cluster_ready + nr=$? + if [[ $nr == 0 ]]; then + echo "Cluster is ready" + break + fi + i=$(( $i + 1 )) + if [[ $i -ge 40 ]]; then + echo "Cluster is not ready.Giving up" + exit 1 + fi + echo "Cluster is not ready...." + sleep 10 + done +} + echo "#########################################" echo "Spawning all hosts" echo "#########################################" @@ -161,6 +196,8 @@ fi sudo chown bird:bird /var/log/bird.log sudo systemctl restart bird +wait_k0s_cluster_ready_full + sleep 30 # Start nginx pods and services for test(using kube-loxilb) @@ -180,5 +217,7 @@ sleep 30 # External LB service must be created by now sudo k0s kubectl get svc +wait_k0s_cluster_ready_full + # Route back to user sudo ip route add 1.1.1.1/32 via 12.12.12.1 diff --git a/cicd/k0s-weave/rmweave.sh b/cicd/k0s-weave/rmweave.sh new file mode 100755 index 000000000..890428c30 --- /dev/null +++ b/cicd/k0s-weave/rmweave.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +sudo curl -L git.io/weave -o /usr/local/bin/weave +sudo chmod a+x /usr/local/bin/weave +weave reset --force +sudo rm -fr /usr/local/bin/weave + +ip a | grep 'vethwepl.*\@' -oP | while read -r line ; do + veth=${line::-1} + if [[ $veth =~ [0-9] ]]; then + echo check $veth + pid=$(echo $veth | tr -dc '0-9') + if ! ps -p $pid > /dev/null; then + echo deleting $veth + ip link delete $veth >&2 + else + echo $veth still running + fi + else + echo $veth veth has no number in it and will not be deleted + fi +done diff --git a/cicd/k3s-calico/config.sh b/cicd/k3s-calico/config.sh index ad9db7699..765d151ea 100755 --- a/cicd/k3s-calico/config.sh +++ b/cicd/k3s-calico/config.sh @@ -1,6 +1,7 @@ #!/bin/bash source ../common.sh +source ../k3s_common.sh echo "#########################################" echo "Spawning all hosts" diff --git a/cicd/k3s-flannel/config.sh b/cicd/k3s-flannel/config.sh index e867bd1c4..31dcfea6f 100755 --- a/cicd/k3s-flannel/config.sh +++ b/cicd/k3s-flannel/config.sh @@ -1,6 +1,7 @@ #!/bin/bash source ../common.sh +source ../k3s_common.sh echo "#########################################" echo "Spawning all hosts"