Skip to content

Commit

Permalink
update nodeips for restore cmd in ko plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Mar 16, 2022
1 parent 621a37f commit 9faf2a1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
13 changes: 10 additions & 3 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2855,13 +2855,20 @@ dbtool(){
# 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}'`
declare nodeIps
if [[ $(kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1]}') =~ "NODE_IPS" ]]; then
nodeIpVals=`kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1].value}'`
nodeIps=(${nodeIpVals//,/ })
else
nodeIps=`kubectl get node -lkube-ovn/role=master -o wide | grep -v "INTERNAL-IP" | awk '{print $6}'`
fi
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
for nodeIp in ${nodeIps[@]}
do
for pod in $podNames
do
Expand All @@ -2877,7 +2884,7 @@ dbtool(){
done
echo "backup nb db file"
docker run -it -v /etc/origin/ovn:/etc/ovn $REGISTRY/kube-ovn:$VERSION bash -c "ovsdb-tool cluster-to-standalone /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db"
kubectl exec -it -n $KUBE_OVN_NS ${podNameArray[0]} -- ovsdb-tool cluster-to-standalone /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db
# mv all db files
for pod in ${podNameArray[@]}
Expand Down
13 changes: 10 additions & 3 deletions dist/images/kubectl-ko
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,20 @@ dbtool(){
# 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}'`
declare nodeIps

if [[ $(kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1]}') =~ "NODE_IPS" ]]; then
nodeIpVals=`kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1].value}'`
nodeIps=(${nodeIpVals//,/ })
else
nodeIps=`kubectl get node -lkube-ovn/role=master -o wide | grep -v "INTERNAL-IP" | awk '{print $6}'`
fi
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
for nodeIp in ${nodeIps[@]}
do
for pod in $podNames
do
Expand All @@ -448,7 +455,7 @@ dbtool(){
done

echo "backup nb db file"
docker run -it -v /etc/origin/ovn:/etc/ovn $REGISTRY/kube-ovn:$VERSION bash -c "ovsdb-tool cluster-to-standalone /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db"
kubectl exec -it -n $KUBE_OVN_NS ${podNameArray[0]} -- ovsdb-tool cluster-to-standalone /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db

# mv all db files
for pod in ${podNameArray[@]}
Expand Down
11 changes: 9 additions & 2 deletions dist/images/restore-ovn-nb-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ 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}'`
declare nodeIps

if [[ $(kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1]}') =~ "NODE_IPS" ]]; then
nodeIpVals=`kubectl get deployment -n kube-system ovn-central -o jsonpath='{.spec.template.spec.containers[0].env[1].value}'`
nodeIps=(${nodeIpVals//,/ })
else
nodeIps=`kubectl get node -lkube-ovn/role=master -o wide | grep -v "INTERNAL-IP" | awk '{print $6}'`
fi
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
for nodeIp in ${nodeIps[@]}
do
for pod in $podNames
do
Expand Down

0 comments on commit 9faf2a1

Please sign in to comment.