-
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.
iptables-rules upgrade compatible (#2429)
* iptables-rules upgrade compatible * Fixed kubectl alias use --------- Co-authored-by: yl4811 <yl4811@yealink.com>
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 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
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 |