update run.sh
This commit is contained in:
parent
f6fa31a48c
commit
6011c75544
61
run.sh
61
run.sh
@ -1,45 +1,49 @@
|
||||
#!/usr/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
set -xeuo pipefail
|
||||
|
||||
function print_help() {
|
||||
cat <<EOF
|
||||
usage:
|
||||
$0 <branch> <k8s_version> <task_number>
|
||||
$0 <branch> <k8s_version> [<task_number>]
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "$#" -lt 3 ]; then
|
||||
if [ "$#" -lt 2 ]; then
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
K8S_VERSIONS="1.26 1.27 1.28 1.29 1.30"
|
||||
function at_err() {
|
||||
if [ -s tmp/hosts ]; then
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh-keygen -R {}
|
||||
fi
|
||||
}
|
||||
|
||||
for k8s_version in $K8S_VERSIONS; do
|
||||
branch="${1:-"sisyphus"}"
|
||||
#k8s_version="${2:-"1.28"}"
|
||||
task_number="${3:-}"
|
||||
ssh_options="-o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
|
||||
trap at_err ERR
|
||||
|
||||
# Create VMs
|
||||
python3 ./main.py
|
||||
branch="$1"
|
||||
k8s_version="$2"
|
||||
task_number="${3:-}"
|
||||
ssh_options="-o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
|
||||
|
||||
# let cloud-init update the system or apt won't be able to get the lock
|
||||
# remove later
|
||||
sleep 80
|
||||
# Create VMs
|
||||
python3 ./main.py
|
||||
|
||||
# Send run/hosts to every vm
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} rsync -e "ssh $ssh_options" tmp/hosts root@{}:/etc/hosts
|
||||
# Restart network on every vm
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh $ssh_options root@{} "systemctl restart network"
|
||||
# Send run/hosts to every vm
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} rsync -e "ssh $ssh_options" tmp/hosts root@{}:/etc/hosts
|
||||
# Restart network on every vm
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh $ssh_options root@{} "systemctl restart network"
|
||||
# Add insecure registry entry
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh $ssh_options root@{} "mkdir -p /etc/containers/registries.conf.d"
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} scp $ssh_options 001-insecure-registries.conf root@{}:/etc/containers/registries.conf.d/001-insecure-registries.conf
|
||||
|
||||
ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \
|
||||
-e task_number="$task_number" -e k8s_version="$k8s_version" -e branch="$branch"
|
||||
ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \
|
||||
-e branch="$branch" -e k8s_version="$k8s_version" -e task_number="$task_number"
|
||||
|
||||
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} rsync root@{}:/etc/kubernetes/admin.conf ~/.kube/config
|
||||
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} rsync --mkpath root@{}:/etc/kubernetes/admin.conf ~/.kube/config
|
||||
|
||||
kubectl apply -f - <<'EOF'
|
||||
kubectl apply -f - <<EOF
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@ -61,7 +65,7 @@ spec:
|
||||
- containerPort: 80
|
||||
EOF
|
||||
|
||||
kubectl apply -f - <<'EOF'
|
||||
kubectl apply -f - <<EOF
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@ -78,11 +82,10 @@ spec:
|
||||
app: nginx
|
||||
EOF
|
||||
|
||||
sleep 120
|
||||
sleep 120
|
||||
|
||||
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} curl {}:30007
|
||||
kubectl exec $(kubectl get po | awk 'END{print $1}') -- nslookup nginx
|
||||
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} curl {}:30007
|
||||
kubectl exec $(kubectl get po | awk 'END{print $1}') -- nslookup nginx
|
||||
|
||||
# Remove ip addresses from known_hosts
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh-keygen -R {}
|
||||
done
|
||||
# Remove ip addresses from known_hosts
|
||||
cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh-keygen -R {}
|
||||
|
Loading…
Reference in New Issue
Block a user