59 lines
1.2 KiB
Bash
Executable File
59 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -exu
|
|
|
|
branch="${1:-"sisyphus"}"
|
|
task_number="${2-}"
|
|
|
|
# Send run/hosts to every vm
|
|
cat tmp/hosts | awk '{print $1}' | xargs -I _ rsync tmp/hosts root@_:/etc/hosts
|
|
# Restart network on every vm
|
|
cat tmp/hosts | awk '{print $1}' | xargs -I _ ssh root@_ "systemctl restart network"
|
|
|
|
ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \
|
|
-e task_number="$task_number"
|
|
|
|
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I _ rsync root@_:/etc/kubernetes/admin.conf ~/.kube/config
|
|
|
|
kubectl apply -f - <<'EOF'
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx-deployment
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: nginx
|
|
replicas: 2 # tells deployment to run 2 pods matching the template
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: nginx
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: obirvalger/my
|
|
ports:
|
|
- containerPort: 80
|
|
EOF
|
|
|
|
kubectl apply -f - <<'EOF'
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: nginx
|
|
labels:
|
|
app: nginx
|
|
spec:
|
|
type: NodePort
|
|
ports:
|
|
- port: 80
|
|
targetPort: 80
|
|
nodePort: 30007
|
|
selector:
|
|
app: nginx
|
|
EOF
|
|
|
|
sleep 180
|
|
|
|
head -n 1 tmp/hosts | awk '{print $1}' | xargs -I _ curl _:30007
|
|
kubectl exec $(kubectl get po | awk 'END{print $1}') -- nslookup nginx
|