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 eb9eada commit a0ab93a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cicd/k3s-sctpmh/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 Expand Up @@ -161,6 +162,9 @@ sudo systemctl restart bird

sleep 10

# Wait for cluster to be ready
wait_cluster_ready_full

# Start nginx pods and services for test(using kube-loxilb)
kubectl $KUBECONFIG apply -f kube-loxilb.yml
sleep 15
Expand All @@ -174,17 +178,28 @@ kubectl $KUBECONFIG apply -f sctp-svc-lb.yml

sleep 50

# Wait for cluster to be ready
wait_cluster_ready_full

# External LB service must be created by now
echo "kubectl $KUBECONFIG get svc"
echo "****************************"
kubectl $KUBECONFIG get svc
echo "kubectl $KUBECONFIG get pods -A"
echo "****************************"
kubectl $KUBECONFIG get pods -A

echo "llb1: loxicmd get lb -o wide"
echo "****************************"
$dexec llb1 loxicmd get lb -o wide
echo "llb1: loxicmd get ep -o wide"
echo "****************************"
$dexec llb1 loxicmd get ep -o wide
$dexec llb1 cat /etc/shared/keepalive.state
echo "llb2: loxicmd get lb -o wide"
echo "****************************"
$dexec llb2 loxicmd get lb -o wide
echo "llb2: loxicmd get ep -o wide"
echo "****************************"
$dexec llb2 loxicmd get ep -o wide
$dexec llb2 cat /etc/shared/keepalive.state


36 changes: 36 additions & 0 deletions cicd/k3s_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

function wait_cluster_ready {
Res=$(sudo kubectl $KUBECONFIG 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
}

0 comments on commit a0ab93a

Please sign in to comment.