-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreset-nodes.sh
executable file
·57 lines (53 loc) · 1.6 KB
/
reset-nodes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
NODES=$(kubectl get nodes -otemplate --template='{{range .items}}{{.metadata.name}} {{end}}')
echo "List of nodes in the cluster: "$NODES
for node in $NODES;
do
echo "Deleting Submariner rules from the node:: "$node
podName=reset-node-$(uuidgen)
kubectl $CONTEXT --v=4 run ${podName} --overrides='{
"spec": {
"hostNetwork": true,
"nodeName": "'$node'",
"containers": [{
"args": [
"/bin/bash", "-c",
"ip xfrm policy flush; ip xfrm state flush; ip link del vx-submariner; ip route flush table 150; iptables -t nat -F SUBMARINER-POSTROUTING;"
],
"stdin": true,
"stdinOnce": true,
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"tty": true,
"securityContext": {
"allowPrivilegeEscalation": true,
"privileged": true,
"runAsUser": 0,
"capabilities": {
"add": ["ALL"]
}
},
"name": "netshoot-hostmount",
"image": "nicolaka/netshoot",
"volumeMounts": [{
"mountPath": "/host",
"name": "host-slash",
"readOnly": true
}]
}],
"restartPolicy": "Never",
"volumes": [{
"hostPath": {
"path": "/",
"type": ""
},
"name": "host-slash"
}]
}
}' --image nicolaka/netshoot -- /bin/bash
while [[ $(kubectl get pods ${podName} -o 'jsonpath={..status.phase}') != "Succeeded" ]]; do echo "Waiting for pod ${podName} to finish..." && sleep 2; done
kubectl delete pod ${podName}
done
echo "Restarting Submariner pods..."
kubectl delete pod -l app=submariner-routeagent -n submariner-operator
kubectl delete pod -l app=submariner-gateway -n submariner-operator