Skip to content

Commit

Permalink
Enhancements to cicd #87
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jun 14, 2023
1 parent 05e2fe4 commit 93bb5a6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 34 deletions.
34 changes: 0 additions & 34 deletions cicd/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
39 changes: 39 additions & 0 deletions cicd/k0s-weave/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "#########################################"
Expand Down Expand Up @@ -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)
Expand All @@ -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
22 changes: 22 additions & 0 deletions cicd/k0s-weave/rmweave.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cicd/k3s-calico/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

source ../common.sh
source ../k3s_common.sh

echo "#########################################"
echo "Spawning all hosts"
Expand Down
1 change: 1 addition & 0 deletions cicd/k3s-flannel/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

source ../common.sh
source ../k3s_common.sh

echo "#########################################"
echo "Spawning all hosts"
Expand Down

0 comments on commit 93bb5a6

Please sign in to comment.