Skip to content

Commit

Permalink
Merge pull request #320 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - Enhancements to cicd:Wait for cluster ready in cluster tests #87
  • Loading branch information
UltraInstinct14 authored Jun 14, 2023
2 parents 0edba81 + 9079a88 commit 558caa0
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions cicd/k3s-cilium-cluster/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ sudo cp /var/lib/rancher/k3s/server/node-token /vagrant/node-token
sudo cp /etc/rancher/k3s/k3s.yaml /vagrant/k3s.yaml
sudo sed -i -e "s/127.0.0.1/${MASTER_IP}/g" /vagrant/k3s.yaml
sudo kubectl apply -f /vagrant/kube-loxilb.yml
/vagrant/wait_ready.sh
37 changes: 37 additions & 0 deletions cicd/k3s-cilium-cluster/wait_ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

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
}
wait_cluster_ready_full
1 change: 1 addition & 0 deletions cicd/k3s-cilium-cluster/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ curl -sfL https://get.k3s.io | K3S_URL="https://${MASTER_ADDR}:6443" K3S_TOKEN="
sudo kubectl apply -f /vagrant/nginx.yml
sudo kubectl apply -f /vagrant/udp.yml
#sudo kubectl apply -f /vagrant/sctp.yml
/vagrant/wait_ready.sh
1 change: 1 addition & 0 deletions cicd/k3s-flannel-cluster/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sudo cp /var/lib/rancher/k3s/server/node-token /vagrant/node-token
sudo cp /etc/rancher/k3s/k3s.yaml /vagrant/k3s.yaml
sudo sed -i -e "s/127.0.0.1/${MASTER_IP}/g" /vagrant/k3s.yaml
sudo kubectl apply -f /vagrant/kube-loxilb.yml
/vagrant/wait_ready.sh
37 changes: 37 additions & 0 deletions cicd/k3s-flannel-cluster/wait_ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

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
}
wait_cluster_ready_full
1 change: 1 addition & 0 deletions cicd/k3s-flannel-cluster/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ curl -sfL https://get.k3s.io | K3S_URL="https://${MASTER_ADDR}:6443" K3S_TOKEN="
sudo kubectl apply -f /vagrant/nginx.yml
sudo kubectl apply -f /vagrant/udp.yml
sudo kubectl apply -f /vagrant/sctp.yml
/vagrant/wait_ready.sh

0 comments on commit 558caa0

Please sign in to comment.