diff --git a/.github/workflows/k3s-flannel-incluster.yml b/.github/workflows/k3s-flannel-incluster.yml index eef233a98..3da4ea13f 100644 --- a/.github/workflows/k3s-flannel-incluster.yml +++ b/.github/workflows/k3s-flannel-incluster.yml @@ -25,6 +25,7 @@ jobs: run: | cd cicd/k3s-flannel-incluster ./config.sh + sleep 90 ./validation.sh cd - diff --git a/cicd/common/sctp_socat_client b/cicd/common/sctp_socat_client new file mode 100755 index 000000000..399c0bd26 Binary files /dev/null and b/cicd/common/sctp_socat_client differ diff --git a/cicd/common/sctp_socat_client.c b/cicd/common/sctp_socat_client.c new file mode 100644 index 000000000..784136cb6 --- /dev/null +++ b/cicd/common/sctp_socat_client.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RECVBUFSIZE 4096 +#define PPID 1234 + +int main(int argc, char* argv[]) +{ + + struct sockaddr_in servaddr = {0}; + struct sockaddr_in laddr = {0}; + int sockfd, in, flags; + char *saddr; + int sport, lport, error = 0; + struct sctp_status status = {0}; + struct sctp_sndrcvinfo sndrcvinfo = {0}; + struct sctp_event_subscribe events = {0}; + struct sctp_initmsg initmsg = {0}; + char msg[1024] = {0}; + char buff[1024] = {0}; + socklen_t opt_len; + socklen_t slen = (socklen_t) sizeof(struct sockaddr_in); + + + sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + lport = atoi(argv[2]); + + laddr.sin_family = AF_INET; + laddr.sin_addr.s_addr = inet_addr(argv[1]); + laddr.sin_port = lport?htons(lport):0; + + //bind to local address + error = bind(sockfd, (struct sockaddr *)&laddr, sizeof(struct sockaddr_in)); + if (error != 0) { + printf("\n\n\t\t***r: error binding addr:" + " %s. ***\n", strerror(errno)); + exit(1); + } + + saddr = argv[3]; + sport = atoi(argv[4]); + bzero( (void *)&servaddr, sizeof(servaddr) ); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons(sport); + servaddr.sin_addr.s_addr = inet_addr( saddr ); + + connect( sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); + + while(1) + { + in = sctp_recvmsg(sockfd, (void*)buff, RECVBUFSIZE, + (struct sockaddr *)&servaddr, + &slen, &sndrcvinfo, &flags); + if (in > 0 && in < RECVBUFSIZE - 1) + { + buff[in] = 0; + printf("%s",buff); + break; + } + } + + close(sockfd); + return 0; +} diff --git a/cicd/k3s-flannel-incluster/Vagrantfile b/cicd/k3s-flannel-incluster/Vagrantfile index d62074c26..3078cfe9e 100644 --- a/cicd/k3s-flannel-incluster/Vagrantfile +++ b/cicd/k3s-flannel-incluster/Vagrantfile @@ -29,8 +29,8 @@ Vagrant.configure("2") do |config| master.vm.network :private_network, ip: "192.168.90.10", :netmask => "255.255.255.0" master.vm.provision :shell, :path => "master1.sh" master.vm.provider :virtualbox do |vbox| - vbox.customize ["modifyvm", :id, "--memory", 8192] - vbox.customize ["modifyvm", :id, "--cpus", 4] + vbox.customize ["modifyvm", :id, "--memory", 4096] + vbox.customize ["modifyvm", :id, "--cpus", 2] vbox.customize ["modifyvm", :id, "--nicpromisc1", "allow-all"] vbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"] end @@ -42,8 +42,8 @@ Vagrant.configure("2") do |config| master.vm.network :private_network, ip: "192.168.90.11", :netmask => "255.255.255.0" master.vm.provision :shell, :path => "master2.sh" master.vm.provider :virtualbox do |vbox| - vbox.customize ["modifyvm", :id, "--memory", 8192] - vbox.customize ["modifyvm", :id, "--cpus", 4] + vbox.customize ["modifyvm", :id, "--memory", 4096] + vbox.customize ["modifyvm", :id, "--cpus", 2] vbox.customize ["modifyvm", :id, "--nicpromisc1", "allow-all"] vbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"] end diff --git a/cicd/k3s-flannel-incluster/host.sh b/cicd/k3s-flannel-incluster/host.sh index c436473e5..bdb9b7356 100755 --- a/cicd/k3s-flannel-incluster/host.sh +++ b/cicd/k3s-flannel-incluster/host.sh @@ -1,10 +1,10 @@ -wget https://github.com/loxilb-io/loxilb/raw/main/cicd/common/sctp_client +wget https://github.com/loxilb-io/loxilb/raw/main/cicd/common/sctp_socat_client wget https://github.com/loxilb-io/loxilb/raw/main/cicd/common/udp_client -chmod 777 sctp_client +chmod 777 sctp_socat_client chmod 777 udp_client echo "123.123.123.1 k8s-svc" >> /etc/hosts -sudo apt install -y bird2 socat +sudo apt install -y bird2 socat lksctp-tools sleep 5 diff --git a/cicd/k3s-flannel-incluster/master1.sh b/cicd/k3s-flannel-incluster/master1.sh index 260a9fb38..c6f0613d1 100755 --- a/cicd/k3s-flannel-incluster/master1.sh +++ b/cicd/k3s-flannel-incluster/master1.sh @@ -1,7 +1,7 @@ sudo su export MASTER_IP=$(ip a |grep global | grep -v '10.0.2.15' | grep -v '192.168.90' | grep '192.168.80' | awk '{print $2}' | cut -f1 -d '/') curl -fL https://get.k3s.io | sh -s - server --node-ip=192.168.80.10 --disable servicelb --disable traefik --cluster-init external-hostname=192.168.80.10 --node-external-ip=192.168.80.10 --disable-cloud-controller -#curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - +curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - sleep 60 echo $MASTER_IP > /vagrant/master-ip cp /var/lib/rancher/k3s/server/node-token /vagrant/node-token diff --git a/cicd/k3s-flannel-incluster/master2.sh b/cicd/k3s-flannel-incluster/master2.sh index ad122e87c..5ec72af6e 100644 --- a/cicd/k3s-flannel-incluster/master2.sh +++ b/cicd/k3s-flannel-incluster/master2.sh @@ -5,6 +5,6 @@ export NODE_TOKEN=$(cat /vagrant/node-token) #curl -fL https://get.k3s.io | K3S_TOKEN=${NODE_TOKEN} sh -s - server --server https://192.168.80.10:6443 --disable traefik --disable servicelb --node-ip=192.168.80.11 external-hostname=192.168.80.11 --node-external-ip=192.168.80.11 --disable-cloud-controller -t ${NODE_TOKEN} curl -fL https://get.k3s.io | K3S_TOKEN=${NODE_TOKEN} sh -s - server --server https://192.168.80.10:6443 --disable traefik --disable servicelb --node-ip=192.168.80.11 external-hostname=192.168.80.11 --node-external-ip=192.168.80.11 -t ${NODE_TOKEN} -#curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - +curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - /vagrant/wait_ready.sh diff --git a/cicd/k3s-flannel-incluster/validation.sh b/cicd/k3s-flannel-incluster/validation.sh index e3ef6b99a..ee8eae48f 100755 --- a/cicd/k3s-flannel-incluster/validation.sh +++ b/cicd/k3s-flannel-incluster/validation.sh @@ -41,7 +41,8 @@ else exit 1 fi -out=$(vagrant ssh host -c "socat -T10 - sctp:$extIP:55004,bind=192.168.90.9") +#vagrant ssh host -c "socat -v -T10 - sctp:$extIP:55004,bind=192.168.90.9 1> /vagrant/log1.txt 2>&1" +out=$(vagrant ssh host -c "timeout 10 ./sctp_socat_client 192.168.90.9 0 $extIP 55004") if [[ ${out} == *"server1"* ]]; then echo "k3s-flannel-cluster (kube-loxilb) sctp [OK]" else @@ -50,7 +51,8 @@ else exit 1 fi -out=$(vagrant ssh host -c "socat -T10 - sctp:$extIP:57004,bind=192.168.90.9") +#vagrant ssh host -c "socat -v -T10 - sctp:$extIP:57004,bind=192.168.90.9 1> /vagrant/log2.txt 2>&1" +out=$(vagrant ssh host -c "timeout 10 ./sctp_socat_client 192.168.90.9 0 $extIP 57004") if [[ ${out} == *"server1"* ]]; then echo "k3s-flannel-cluster (kube-loxilb) default-sctp [OK]" else diff --git a/cicd/k8s-calico-ubuntu22/validation.sh b/cicd/k8s-calico-ubuntu22/validation.sh index 131be315b..7455a4f80 100755 --- a/cicd/k8s-calico-ubuntu22/validation.sh +++ b/cicd/k8s-calico-ubuntu22/validation.sh @@ -86,7 +86,7 @@ else code=1 fi -out=$(timeout 10 ../common/sctp_client 192.168.90.1 34951 $extIP ${sctp_port[i]}) +out=$(timeout 10 ../common/sctp_socat_client 192.168.90.1 34951 $extIP ${sctp_port[i]}) if [[ ${out} == *"server1"* ]]; then echo -e "K8s-calico-Ubuntu22 SCTP\t(${mode[i]})\t[OK]" else diff --git a/cicd/k8s-calico/validation.sh b/cicd/k8s-calico/validation.sh index dc9d77851..06100d862 100755 --- a/cicd/k8s-calico/validation.sh +++ b/cicd/k8s-calico/validation.sh @@ -86,7 +86,7 @@ else code=1 fi -out=$(timeout 5 ../common/sctp_client 192.168.90.1 34951 $extIP ${sctp_port[i]}) +out=$(timeout 5 ../common/sctp_socat_client 192.168.90.1 34951 $extIP ${sctp_port[i]}) if [[ ${out} == *"server1"* ]]; then echo -e "K8s-calico SCTP\t(${mode[i]})\t[OK]" else