Skip to content

Commit

Permalink
iptables-rules upgrade compatible (#2429)
Browse files Browse the repository at this point in the history
* iptables-rules upgrade compatible

* Fixed kubectl alias use

---------

Co-authored-by: yl4811 <yl4811@yealink.com>
  • Loading branch information
ShaPoHun and yl4811 authored Mar 7, 2023
1 parent 5703384 commit a99ceb2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions dist/images/update/1.10-1.11.2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -eo pipefail

echo "begin upgrade iptables-dnat-rules"
all_dnat=$(kubectl get dnat -o name)
for dnat in $all_dnat;do
nat_anno=$(kubectl get $dnat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $dnat -o jsonpath='{.spec.eip}')
kubectl annotate $dnat ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
if [ -n "$eip_anno" ];then
continue
fi
echo "annotate $eip ovn.kubernetes.io/vpc_nat"
nat_name=$(kubectl get $dnat -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

echo "begin annotate iptables-snat-rules.kubeovn.io"
all_snat=$(kubectl get snat -o name)
for snat in $all_snat;do
nat_anno=$(kubectl get $snat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $snat -o jsonpath='{.spec.eip}')
kubectl annotate $snat ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
if [ -n "$eip_anno" ];then
continue
fi
nat_name=$(kubectl get $snat -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

echo "begin annotate iptables-fip-rules.kubeovn.io"
all_fip=$(kubectl get fip -o name)
for fip in $all_fip;do
nat_anno=$(kubectl get $fip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $fip -o jsonpath='{.spec.eip}')
kubectl annotate $fip ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
if [ -n "$eip_anno" ];then
continue
fi
nat_name=$(kubectl get $snat -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

0 comments on commit a99ceb2

Please sign in to comment.