diff --git a/cicd/k3s-flannel/config.sh b/cicd/k3s-flannel/config.sh index 94e4ede0b..f7cf30e1c 100755 --- a/cicd/k3s-flannel/config.sh +++ b/cicd/k3s-flannel/config.sh @@ -7,8 +7,8 @@ echo "#########################################" echo "Spawning all hosts" echo "#########################################" -spawn_docker_host --dock-type loxilb --dock-name llb1 --with-bgp yes --bgp-config $(pwd)/llb1_gobgp_config --with-ka in --ka-config $(pwd)/keepalived_config1 -spawn_docker_host --dock-type loxilb --dock-name llb2 --with-bgp yes --bgp-config $(pwd)/llb2_gobgp_config --with-ka in --ka-config $(pwd)/keepalived_config2 +spawn_docker_host --dock-type loxilb --dock-name llb1 --with-bgp yes --bgp-config $(pwd)/llb1_gobgp_config --with-ka in +spawn_docker_host --dock-type loxilb --dock-name llb2 --with-bgp yes --bgp-config $(pwd)/llb2_gobgp_config --with-ka in spawn_docker_host --dock-type host --dock-name ep1 spawn_docker_host --dock-type host --dock-name ep2 spawn_docker_host --dock-type host --dock-name ep3 @@ -98,6 +98,10 @@ $hexec r1 ip route add 20.20.20.1/32 via 11.11.11.11 #add_route llb1 1.1.1.0/24 11.11.11.254 #add_route llb2 1.1.1.0/24 11.11.11.254 +## host network +sudo ip route add 11.11.11.11/32 via 14.14.14.1 +sudo ip route add 123.123.123.1/32 via 14.14.14.1 + sleep 1 ##Create LB rule create_lb_rule llb1 20.20.20.1 --tcp=2020:8080 --endpoints=31.31.31.1:1,32.32.32.1:1,33.33.33.1:1 --mode=fullnat --bgp @@ -157,8 +161,8 @@ wait_cluster_ready_full sleep 10 # Start nginx pods and services for test -kubectl $KUBECONFIG apply -f nginx.yml -kubectl $KUBECONFIG apply -f nginx-svc-lb.yml +#kubectl $KUBECONFIG apply -f nginx.yml +#kubectl $KUBECONFIG apply -f nginx-svc-lb.yml sleep 5 diff --git a/cicd/k3s-flannel/nginx-svc-lb1.yml b/cicd/k3s-flannel/nginx-svc-lb1.yml index 5bcf72fd4..18d56f78b 100644 --- a/cicd/k3s-flannel/nginx-svc-lb1.yml +++ b/cicd/k3s-flannel/nginx-svc-lb1.yml @@ -2,6 +2,9 @@ apiVersion: v1 kind: Service metadata: name: nginx-lb1 + annotations: + loxilb.io/staticIP : "11.11.11.11" + loxilb.io/lbmode: "fullnat" spec: externalTrafficPolicy: Local loadBalancerClass: loxilb.io/loxilb diff --git a/cicd/k3s-flannel/rmconfig.sh b/cicd/k3s-flannel/rmconfig.sh index ed8c9acb2..0ad725ad6 100755 --- a/cicd/k3s-flannel/rmconfig.sh +++ b/cicd/k3s-flannel/rmconfig.sh @@ -10,6 +10,9 @@ fi source ../common.sh +sudo ip route del 11.11.11.11/32 via 14.14.14.1 +sudo ip route del 123.123.123.1/32 via 14.14.14.1 + sudo kubectl $KUBECONFIG delete -f nginx-svc-lb1.yml >> /dev/null 2>&1 sudo kubectl $KUBECONFIG delete -f nginx-svc-lb.yml >> /dev/null 2>&1 sudo kubectl $KUBECONFIG delete -f nginx.yml >> /dev/null 2>&1 diff --git a/cicd/k3s-flannel/validation.sh b/cicd/k3s-flannel/validation.sh index 63fb8d6a3..4d7f49445 100755 --- a/cicd/k3s-flannel/validation.sh +++ b/cicd/k3s-flannel/validation.sh @@ -11,7 +11,7 @@ IFS=' ' for((i=0; i<120; i++)) do - extLB=$(sudo kubectl $KUBECONFIG get svc | grep "nginx-lb") + extLB=$(sudo kubectl $KUBECONFIG get svc | grep "nginx-lb1") read -a strarr <<< "$extLB" len=${#strarr[*]} if [[ $((len)) -lt 6 ]]; then @@ -58,15 +58,7 @@ print_debug_info() { } code=0 -print_debug_info - -out=$($hexec user curl -s --connect-timeout 10 http://$extIP:80) -if [[ ${out} == *"Welcome to nginx"* ]]; then - echo "cluster-k3s (ccm) [OK]" -else - echo "cluster-k3s (ccm) [FAILED]" - code=1 -fi +#print_debug_info out=$($hexec user curl -s --connect-timeout 10 http://$extIP:55002) if [[ ${out} == *"Welcome to nginx"* ]]; then @@ -76,6 +68,24 @@ else code=1 fi +for((i=0; i<120; i++)) +do + extLB=$(sudo kubectl $KUBECONFIG get svc | grep "udp-lb1") + read -a strarr <<< "$extLB" + len=${#strarr[*]} + if [[ $((len)) -lt 6 ]]; then + echo "Can't find udp-lb service" + sleep 1 + continue + fi + if [[ ${strarr[3]} != *"none"* ]]; then + extIP="$(cut -d'-' -f2 <<<${strarr[3]})" + break + fi + echo "No external LB allocated" + sleep 1 +done + out=$($hexec user timeout 30 ../common/udp_client $extIP 55003) if [[ ${out} == *"Client"* ]]; then echo "cluster-k3s (kube-loxilb) udp [OK]" @@ -85,6 +95,7 @@ else fi if [[ $code -eq 1 ]]; then + print_debug_info echo "cluster-k3s failed" exit 1 fi