-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9a4bd5
commit 44dae1f
Showing
9 changed files
with
199 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
KUBE_OVN_NS=kube-system | ||
# set ovn-central replicas to 0 | ||
replicas=$(kubectl get deployment -n $KUBE_OVN_NS ovn-central -o jsonpath={.spec.replicas}) | ||
kubectl scale deployment -n $KUBE_OVN_NS ovn-central --replicas=0 | ||
echo "ovn-central original replicas is $replicas" | ||
|
||
# backup ovn-nb db | ||
declare nodeIpArray | ||
declare podNameArray | ||
nodeIps=`kubectl get node -lkube-ovn/role=master -o wide | grep -v "INTERNAL-IP" | awk '{print $6}'` | ||
firstIP=${nodeIps[0]} | ||
podNames=`kubectl get pod -n $KUBE_OVN_NS | grep ovs-ovn | awk '{print $1}'` | ||
echo "first nodeIP is $firstIP" | ||
|
||
i=0 | ||
for nodeIp in $nodeIps | ||
do | ||
for pod in $podNames | ||
do | ||
hostip=$(kubectl get pod -n $KUBE_OVN_NS $pod -o jsonpath={.status.hostIP}) | ||
if [ $nodeIp = $hostip ]; then | ||
nodeIpArray[$i]=$nodeIp | ||
podNameArray[$i]=$pod | ||
i=`expr $i + 1` | ||
echo "ovs-ovn pod on node $nodeIp is $pod" | ||
break | ||
fi | ||
done | ||
done | ||
|
||
echo "backup nb db file" | ||
ovsdb-tool cluster-to-standalone /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db | ||
|
||
# mv all db files | ||
for pod in ${podNameArray[@]} | ||
do | ||
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv /etc/ovn/ovnnb_db.db /tmp | ||
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv /etc/ovn/ovnsb_db.db /tmp | ||
done | ||
|
||
# restore db and replicas | ||
echo "restore nb db file" | ||
mv /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db | ||
kubectl scale deployment -n $KUBE_OVN_NS ovn-central --replicas=$replicas | ||
echo "finish restore nb db file and ovn-central replicas" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,6 +714,7 @@ rules: | |
- statefulsets | ||
- daemonsets | ||
- deployments | ||
- deployments/scale | ||
verbs: | ||
- create | ||
- delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -768,6 +768,7 @@ rules: | |
- statefulsets | ||
- daemonsets | ||
- deployments | ||
- deployments/scale | ||
verbs: | ||
- create | ||
- delete | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ rules: | |
- statefulsets | ||
- daemonsets | ||
- deployments | ||
- deployments/scale | ||
verbs: | ||
- get | ||
- list | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ rules: | |
- statefulsets | ||
- daemonsets | ||
- deployments | ||
- deployments/scale | ||
verbs: | ||
- get | ||
- list | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,7 @@ rules: | |
- statefulsets | ||
- daemonsets | ||
- deployments | ||
- deployments/scale | ||
verbs: | ||
- create | ||
- delete | ||
|