-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathipfailover_service.sh
executable file
·46 lines (37 loc) · 1.28 KB
/
ipfailover_service.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
#!/bin/bash
node1=ose-node1.bmeng.local
node2=ose-node2.bmeng.local
ip="10.66.140.105-106"
# check ips
for i in 105 106
do
ping -c1 10.66.140.$i
if [ $? -ne 1 ]
then
exit
fi
done
# add labels to node
oc label node $node1 ha-service=ha --overwrite
oc label node $node2 ha-service=ha --overwrite
# create router on each node
oc adm policy add-scc-to-user privileged -z default
oc create -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/networking/ha-network-service.json
# wait the routers are running
while [ `oc get pod | grep ha | grep Running | wc -l` -lt 2 ]
do
sleep 5
done
oc patch svc ha-service -p '{"spec": {"ports": [{"port":9736,"targetPort":8080}]}}'
oc patch svc ha-service -p '{"spec": {"type":"NodePort"}}'
nodeport=`oc get svc ha-service -o jsonpath={.spec.ports[0].nodePort}`
# for i in $node1 $node2 ;do curl $i:9736 ; done
# create ipfailover for each router
oc adm policy add-scc-to-user privileged -z ipfailover
oc adm ipfailover ipf --create --selector=ha-service=ha --virtual-ips=${ip} --watch-port=${nodeport} --replicas=2 --service-account=ipfailover --interface=eth0
# wait the keepaliveds are running
while [ `oc get pod | grep ipf | grep -v deploy | grep Running | wc -l` -lt 2 ]
do
sleep 5
done
for i in $node1 $node2 ;do curl $i:$nodeport ; done