From 095e06a0d3f1e80e01aaec5a7e42f0787d0942d7 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 1 Sep 2023 12:00:04 +0900 Subject: [PATCH 1/4] updated cicd for calico with kube-proxy(ipvs) --- cicd/k8s-calico-ipvs/Vagrantfile | 78 ++++++++++ cicd/k8s-calico-ipvs/config.sh | 49 +++++++ cicd/k8s-calico-ipvs/configs/config | 19 +++ cicd/k8s-calico-ipvs/configs/join.sh | 1 + cicd/k8s-calico-ipvs/input | 6 + cicd/k8s-calico-ipvs/node_scripts/common.sh | 93 ++++++++++++ cicd/k8s-calico-ipvs/node_scripts/loxilb.sh | 13 ++ cicd/k8s-calico-ipvs/node_scripts/master.sh | 65 +++++++++ cicd/k8s-calico-ipvs/node_scripts/worker.sh | 27 ++++ cicd/k8s-calico-ipvs/rmconfig.sh | 9 ++ cicd/k8s-calico-ipvs/validation.sh | 119 ++++++++++++++++ cicd/k8s-calico-ipvs/yaml/kube-loxilb.yml | 134 ++++++++++++++++++ cicd/k8s-calico-ipvs/yaml/kubeadm-config.yaml | 69 +++++++++ cicd/k8s-calico-ipvs/yaml/sctp.yml | 41 ++++++ cicd/k8s-calico-ipvs/yaml/sctp_fullnat.yml | 39 +++++ cicd/k8s-calico-ipvs/yaml/sctp_onearm.yml | 41 ++++++ cicd/k8s-calico-ipvs/yaml/settings.yaml | 44 ++++++ cicd/k8s-calico-ipvs/yaml/tcp.yml | 29 ++++ cicd/k8s-calico-ipvs/yaml/tcp_fullnat.yml | 29 ++++ cicd/k8s-calico-ipvs/yaml/tcp_onearm.yml | 29 ++++ cicd/k8s-calico-ipvs/yaml/udp.yml | 30 ++++ cicd/k8s-calico-ipvs/yaml/udp_fullnat.yml | 30 ++++ cicd/k8s-calico-ipvs/yaml/udp_onearm.yml | 30 ++++ 23 files changed, 1024 insertions(+) create mode 100644 cicd/k8s-calico-ipvs/Vagrantfile create mode 100755 cicd/k8s-calico-ipvs/config.sh create mode 100644 cicd/k8s-calico-ipvs/configs/config create mode 100755 cicd/k8s-calico-ipvs/configs/join.sh create mode 100644 cicd/k8s-calico-ipvs/input create mode 100644 cicd/k8s-calico-ipvs/node_scripts/common.sh create mode 100644 cicd/k8s-calico-ipvs/node_scripts/loxilb.sh create mode 100644 cicd/k8s-calico-ipvs/node_scripts/master.sh create mode 100644 cicd/k8s-calico-ipvs/node_scripts/worker.sh create mode 100755 cicd/k8s-calico-ipvs/rmconfig.sh create mode 100755 cicd/k8s-calico-ipvs/validation.sh create mode 100644 cicd/k8s-calico-ipvs/yaml/kube-loxilb.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/kubeadm-config.yaml create mode 100644 cicd/k8s-calico-ipvs/yaml/sctp.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/sctp_fullnat.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/sctp_onearm.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/settings.yaml create mode 100644 cicd/k8s-calico-ipvs/yaml/tcp.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/tcp_fullnat.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/tcp_onearm.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/udp.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/udp_fullnat.yml create mode 100644 cicd/k8s-calico-ipvs/yaml/udp_onearm.yml diff --git a/cicd/k8s-calico-ipvs/Vagrantfile b/cicd/k8s-calico-ipvs/Vagrantfile new file mode 100644 index 000000000..6aac7e084 --- /dev/null +++ b/cicd/k8s-calico-ipvs/Vagrantfile @@ -0,0 +1,78 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +require "yaml" +settings = YAML.load_file "yaml/settings.yaml" + +workers = settings["nodes"]["workers"]["count"] + +Vagrant.configure("2") do |config| + + if Vagrant.has_plugin?("vagrant-vbguest") + config.vbguest.auto_update = false + end + + config.vm.define "loxilb" do |loxilb| + loxilb.vm.box = settings["software"]["loxilb"]["box"]["name"] + loxilb.vm.box_version = settings["software"]["loxilb"]["box"]["version"] + loxilb.vm.hostname = 'llb1' + #loxilb.vm.network "forwarded_port", guest: 55002, host: 5502, protocol: "tcp" + loxilb.vm.network :private_network, ip: settings["network"]["iloxilb_ip"], :netmask => "255.255.255.0" + loxilb.vm.network :private_network, ip: settings["network"]["oloxilb_ip"], :netmask => "255.255.255.0" + loxilb.vm.provision :shell, :path => "node_scripts/loxilb.sh" + loxilb.vm.provider :virtualbox do |vbox| + vbox.customize ["modifyvm", :id, "--memory", 6000] + vbox.customize ["modifyvm", :id, "--cpus", 4] + end + end + + + config.vm.box = settings["software"]["cluster"]["box"] + config.vm.define "master" do |master| + master.vm.hostname = 'master' + master.vm.network :private_network, ip: settings["network"]["control_ip"], :netmask => "255.255.255.0" + master.vm.provision "shell", + env: { + "DNS_SERVERS" => settings["network"]["dns_servers"].join(" "), + "ENVIRONMENT" => settings["environment"], + "KUBERNETES_VERSION" => settings["software"]["kubernetes"], + "OS" => settings["software"]["os"] + }, + path: "node_scripts/common.sh" + master.vm.provision "shell", + env: { + "CALICO_VERSION" => settings["software"]["calico"], + "CONTROL_IP" => settings["network"]["control_ip"], + "POD_CIDR" => settings["network"]["pod_cidr"], + "SERVICE_CIDR" => settings["network"]["service_cidr"] + }, + path: "node_scripts/master.sh" + + master.vm.provider :virtualbox do |vbox| + vbox.customize ["modifyvm", :id, "--memory", 4096] + vbox.customize ["modifyvm", :id, "--cpus", 2] + end + end + + (1..workers).each do |node_number| + config.vm.define "worker#{node_number}" do |worker| + worker.vm.hostname = "worker#{node_number}" + ip = node_number + 100 + worker.vm.network :private_network, ip: "192.168.80.#{ip}", :netmask => "255.255.255.0" + worker.vm.provision "shell", + env: { + "DNS_SERVERS" => settings["network"]["dns_servers"].join(" "), + "ENVIRONMENT" => settings["environment"], + "KUBERNETES_VERSION" => settings["software"]["kubernetes"], + "OS" => settings["software"]["os"] + }, + path: "node_scripts/common.sh" + worker.vm.provision "shell", path: "node_scripts/worker.sh" + + worker.vm.provider :virtualbox do |vbox| + vbox.customize ["modifyvm", :id, "--memory", 4096] + vbox.customize ["modifyvm", :id, "--cpus", 2] + end + end + end +end diff --git a/cicd/k8s-calico-ipvs/config.sh b/cicd/k8s-calico-ipvs/config.sh new file mode 100755 index 000000000..f7f9ea429 --- /dev/null +++ b/cicd/k8s-calico-ipvs/config.sh @@ -0,0 +1,49 @@ +#!/bin/bash +VMs=$(vagrant global-status | grep -i virtualbox) +while IFS= read -a VMs; do + read -a vm <<< "$VMs" + cd ${vm[4]} 2>&1>/dev/null + echo "Destroying ${vm[1]}" + vagrant destroy -f ${vm[1]} + cd - 2>&1>/dev/null +done <<< "$VMs" + +vagrant up +sudo ip route add 123.123.123.1 via 192.168.90.9 +sudo ip route add 124.124.124.1 via 192.168.90.9 +sudo ip route add 125.125.125.1 via 192.168.90.9 + +for((i=1; i<=60; i++)) +do + fin=1 + pods=$(vagrant ssh master -c 'kubectl get pods -A' 2> /dev/null | grep -v "NAMESPACE") + + while IFS= read -a pods; do + read -a pod <<< "$pods" + if [[ ${pod[3]} != *"Running"* ]]; then + echo "${pod[1]} is not UP yet" + fin=0 + fi + done <<< "$pods" + if [ $fin == 1 ]; + then + break; + fi + echo "Will try after 10s" + sleep 10 +done + +#Create default Service +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/tcp.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/udp.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/sctp.yml' 2> /dev/null + +#Create onearm Service +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/tcp_onearm.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/udp_onearm.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/sctp_onearm.yml' 2> /dev/null + +#Create fullnat Service +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/tcp_fullnat.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/udp_fullnat.yml' 2> /dev/null +vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/sctp_fullnat.yml' 2> /dev/null diff --git a/cicd/k8s-calico-ipvs/configs/config b/cicd/k8s-calico-ipvs/configs/config new file mode 100644 index 000000000..752bd5ddf --- /dev/null +++ b/cicd/k8s-calico-ipvs/configs/config @@ -0,0 +1,19 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJek1Ea3dNVEF5TkRZek9Gb1hEVE16TURneU9UQXlORFl6T0Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBSzhTCkZwZTh0UVlQOVdvVTZYNVAwanBuSHMxM1hYQ3NnVk03QjJDRG5NWGpFeEExbm9xWElybk1YbFlmVTZ2blhLbSsKUDRqRGFUM0puK1hxaHFLUml3dmkra01lL1FUSVJiUThwVmVtUnBXaDB0dWNPbTJmeno0UkQxeS83ZmJHd0VGWgpCM3BRNm9CSVdXR0F3VERISDdoU0RlU0czdnhFRzdMdVNnUElxYWM1MEpkVWYrVXJ5SUlzdTlnYkJZN2NGcjhzCm03YmFTUkF5NkZyWlRveTBPRW1sT2NWWTBWYUpZdWpPdmVkTk5KRkw1RTlCenArbjA0UVcwVjRRd0NDaUIwQ3EKRjJTdWo4aDRSZWk0VTE5WmkvN2FyYyt5MTZUbURXem00Y0FRa05DWEY4dExYRTlMb3hUVEgvdGJFUHhORUk0KwpDT1BGZ0puVjd4R0l2QVh5UEVzQ0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZJTHBkU2YrYzhZS0tlb0ZQVk1pUFZQWVREaUdNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBS2JtYnBzTlF4UlFvTjRuMnUxOQo5Ump0WTJvMmUvSFA3NCthdlVKRitqM3FqRGFSdnhBS3JFRVNLMGJ1WmpFNzdQcmNtRnB3UFRmQ2wxazRDV2hyCnhPM1U0a2tXamQrWXlGc3BVYjJIaUE5R3ZhTXczWDBxaWtDRGZjNGxIaExXOWtRMWNpUHNyMmhPQURyZ2hNVUgKWWxEM2RBSnRuZzRXVm5TU2NiODk3Vm9DUU56NExlNi9WaWszRXA2ZG9pb1ZQbTZsNW9JNlU1ODJPMlorSGkwYgo4bzgxK3QxRVBvZ01tQkJWMVdWSzd4UkVLRFJuMmgzQjY4NHc0TGgyNkdyQ1NZVGlwRGhjUGJmRFJvS2o4aEFZClM0YWFRSDJLZ2kvdnkvY0VPVXc1Sk9VdmZBWUlmQ0R1d3k4K1NlOUc5NStaZStoTGdUcHkvZ3hTMHNhN20xTVQKM3FRPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + server: https://192.168.80.10:6443 + name: kubernetes +contexts: +- context: + cluster: kubernetes + user: kubernetes-admin + name: kubernetes-admin@kubernetes +current-context: kubernetes-admin@kubernetes +kind: Config +preferences: {} +users: +- name: kubernetes-admin + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJTjd6VjBzQnlrQUF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TXpBNU1ERXdNalEyTXpoYUZ3MHlOREE0TXpFd01qUTJOREZhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpM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pZUUtCZ1FEZSt1dnFPQ2F3dk9GQ2J2N3IyUXdIN3pHLzJMdXJqMHd0UENYd09IbXFiWWpvSnhEZGlyd2oKc0JsOXUxTzNLVkR5TmJGS2NHOUFyVmlEU3JOUFkrNEdiZCtqYTlheHFVUGZHU3pBWDlwRUdDcmdacHRrK0d0Ngo5SFBsbkFsYXpzTWgyUGhxSlN4U3ZRQ2h3QXk0cmZMdlltMVhkYjhaYnkrVndCTlZVL21obXc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= diff --git a/cicd/k8s-calico-ipvs/configs/join.sh b/cicd/k8s-calico-ipvs/configs/join.sh new file mode 100755 index 000000000..0cde2a766 --- /dev/null +++ b/cicd/k8s-calico-ipvs/configs/join.sh @@ -0,0 +1 @@ +kubeadm join 192.168.80.10:6443 --token erzh6n.ysnbfgbxinfum5ps --discovery-token-ca-cert-hash sha256:43c9a9c2b22f053d87a0e11df980c04f8171778049609a62d29db794e30ece03 diff --git a/cicd/k8s-calico-ipvs/input b/cicd/k8s-calico-ipvs/input new file mode 100644 index 000000000..6fb66a5e2 --- /dev/null +++ b/cicd/k8s-calico-ipvs/input @@ -0,0 +1,6 @@ + + + + + + diff --git a/cicd/k8s-calico-ipvs/node_scripts/common.sh b/cicd/k8s-calico-ipvs/node_scripts/common.sh new file mode 100644 index 000000000..b8634194f --- /dev/null +++ b/cicd/k8s-calico-ipvs/node_scripts/common.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# Common setup for all servers (Control Plane and Nodes) + +set -euxo pipefail + +# Variable Declaration + +# DNS Setting +if [ ! -d /etc/systemd/resolved.conf.d ]; then + sudo mkdir /etc/systemd/resolved.conf.d/ +fi +cat </dev/null; echo "@reboot /sbin/swapoff -a") | crontab - || true +sudo apt-get update -y +# Install CRI-O Runtime + +VERSION="$(echo ${KUBERNETES_VERSION} | grep -oE '[0-9]+\.[0-9]+')" + +# Create the .conf file to load the modules at bootup +cat <> /etc/default/crio << EOF +${ENVIRONMENT} +EOF +sudo systemctl daemon-reload +sudo systemctl enable crio --now + +echo "CRI runtime installed successfully" + +sudo apt-get update +sudo apt-get install -y apt-transport-https ca-certificates curl +curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list +sudo apt-get update -y +sudo apt-get install -y kubelet="$KUBERNETES_VERSION" kubectl="$KUBERNETES_VERSION" kubeadm="$KUBERNETES_VERSION" +sudo apt-get update -y +sudo apt-get install -y jq +sudo apt-get install -y ipvsadm + +local_ip="$(ip --json a s | jq -r '.[] | if .ifname == "eth1" then .addr_info[] | if .family == "inet" then .local else empty end else empty end')" +cat > /etc/default/kubelet << EOF +KUBELET_EXTRA_ARGS=--node-ip=$local_ip +${ENVIRONMENT} +EOF diff --git a/cicd/k8s-calico-ipvs/node_scripts/loxilb.sh b/cicd/k8s-calico-ipvs/node_scripts/loxilb.sh new file mode 100644 index 000000000..546301eba --- /dev/null +++ b/cicd/k8s-calico-ipvs/node_scripts/loxilb.sh @@ -0,0 +1,13 @@ +export LOXILB_IP=$(ip a |grep global | grep -v '10.0.2.15' | grep -v '192.168.80' | awk '{print $2}' | cut -f1 -d '/') + +apt-get update +apt-get install -y software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +apt-get update +apt-get install -y docker-ce +docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --net=host --name loxilb ghcr.io/loxilb-io/loxilb:latest --ka=out +echo alias loxicmd=\"sudo docker exec -it loxilb loxicmd\" >> ~/.bashrc +echo alias loxilb=\"sudo docker exec -it loxilb \" >> ~/.bashrc + +echo $LOXILB_IP > /vagrant/loxilb-ip diff --git a/cicd/k8s-calico-ipvs/node_scripts/master.sh b/cicd/k8s-calico-ipvs/node_scripts/master.sh new file mode 100644 index 000000000..9e65ff335 --- /dev/null +++ b/cicd/k8s-calico-ipvs/node_scripts/master.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Setup for Control Plane (Master) servers + +set -euxo pipefail + +NODENAME=$(hostname -s) + +sudo kubeadm config images pull + +echo "Preflight Check Passed: Downloaded All Required Images" + +#sudo kubeadm init --apiserver-advertise-address=$CONTROL_IP --apiserver-cert-extra-sans=$CONTROL_IP --pod-network-cidr=$POD_CIDR --service-cidr=$SERVICE_CIDR --node-name "$NODENAME" --ignore-preflight-errors Swap +sudo kubeadm init --ignore-preflight-errors Swap --config /vagrant/yaml/kubeadm-config.yaml + +mkdir -p "$HOME"/.kube +sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config +sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config + +# Save Configs to shared /Vagrant location + +# For Vagrant re-runs, check if there is existing configs in the location and delete it for saving new configuration. + +config_path="/vagrant/configs" + +if [ -d $config_path ]; then + rm -f $config_path/* +else + mkdir -p $config_path +fi + +cp -i /etc/kubernetes/admin.conf $config_path/config +touch $config_path/join.sh +chmod +x $config_path/join.sh + +kubeadm token create --print-join-command > $config_path/join.sh + +# Install Calico Network Plugin + +curl https://raw.githubusercontent.com/projectcalico/calico/v${CALICO_VERSION}/manifests/calico.yaml -O + +kubectl apply -f calico.yaml + +sudo -i -u vagrant bash << EOF +whoami +mkdir -p /home/vagrant/.kube +sudo cp -i $config_path/config /home/vagrant/.kube/ +sudo chown 1000:1000 /home/vagrant/.kube/config +EOF + +# Install Metrics Server + +kubectl apply -f https://raw.githubusercontent.com/techiescamp/kubeadm-scripts/main/manifests/metrics-server.yaml + +# Install loxilb +kubectl apply -f /vagrant/yaml/kube-loxilb.yml + +#Install routes for pod to client (fullnat service) in nodes +sudo ip route add 9.9.9.9 via 192.168.80.9 +sudo ip route add 123.123.123.1 via 192.168.80.9 +sudo ip route add 124.124.124.1 via 192.168.80.9 +sudo ip route add 125.125.125.1 via 192.168.80.9 + +#Install routes for pod to client (default service) in nodes +sudo ip route add 192.168.90.0/24 via 192.168.80.9 diff --git a/cicd/k8s-calico-ipvs/node_scripts/worker.sh b/cicd/k8s-calico-ipvs/node_scripts/worker.sh new file mode 100644 index 000000000..bb11a0518 --- /dev/null +++ b/cicd/k8s-calico-ipvs/node_scripts/worker.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Setup for Node servers + +set -euxo pipefail + +config_path="/vagrant/configs" + +/bin/bash $config_path/join.sh -v + +sudo -i -u vagrant bash << EOF +whoami +mkdir -p /home/vagrant/.kube +sudo cp -i $config_path/config /home/vagrant/.kube/ +sudo chown 1000:1000 /home/vagrant/.kube/config +NODENAME=$(hostname -s) +kubectl label node $(hostname -s) node-role.kubernetes.io/worker=worker +EOF + +#Install routes for pod to client (fullnat service) in nodes +sudo ip route add 123.123.123.1 via 192.168.80.9 +sudo ip route add 124.124.124.1 via 192.168.80.9 +sudo ip route add 125.125.125.1 via 192.168.80.9 +sudo ip route add 9.9.9.9 via 192.168.80.9 + +#Install routes for pod to client (default service) in nodes +sudo ip route add 192.168.90.0/24 via 192.168.80.9 diff --git a/cicd/k8s-calico-ipvs/rmconfig.sh b/cicd/k8s-calico-ipvs/rmconfig.sh new file mode 100755 index 000000000..1801a6184 --- /dev/null +++ b/cicd/k8s-calico-ipvs/rmconfig.sh @@ -0,0 +1,9 @@ +#!/bin/bash +sudo ip route del 123.123.123.1 via 192.168.90.9 +sudo ip route del 124.124.124.1 via 192.168.90.9 +sudo ip route del 125.125.125.1 via 192.168.90.9 +vagrant destroy -f worker2 +vagrant destroy -f worker1 +vagrant destroy -f master +vagrant destroy -f loxilb +sudo rm loxilb-ip diff --git a/cicd/k8s-calico-ipvs/validation.sh b/cicd/k8s-calico-ipvs/validation.sh new file mode 100755 index 000000000..0cbcca4fd --- /dev/null +++ b/cicd/k8s-calico-ipvs/validation.sh @@ -0,0 +1,119 @@ +#!/bin/bash +source ../common.sh +echo k8s-calico-ipvs + +if [ "$1" ]; then + KUBECONFIG="$1" +fi + +# Set space as the delimiter +IFS=' ' + +for((i=0; i<120; i++)) +do + extLB=$(vagrant ssh master -c 'kubectl get svc' 2> /dev/null | grep "tcp-lb-default") + read -a strarr <<< "$extLB" + len=${#strarr[*]} + if [[ $((len)) -lt 6 ]]; then + echo "Can't find tcp-lb service" + sleep 1 + continue + fi + if [[ ${strarr[3]} != *"none"* ]]; then + extIP=${strarr[3]} + break + fi + echo "No external LB allocated" + sleep 1 +done + +## Any routing updates ?? +sleep 30 + +echo Service IP : $extIP +echo -e "\nEnd Points List" +echo "******************************************************************************" +vagrant ssh master -c 'kubectl get endpoints -A' 2> /dev/null +echo "******************************************************************************" +echo -e "\nSVC List" +echo "******************************************************************************" +vagrant ssh master -c 'kubectl get svc' 2> /dev/null +echo "******************************************************************************" +echo -e "\nPod List" +echo "******************************************************************************" +vagrant ssh master -c 'kubectl get pods -A' 2> /dev/null +echo "******************************************************************************" +echo -e "\nLB List" +echo "******************************************************************************" +vagrant ssh loxilb -c 'sudo docker exec -it loxilb loxicmd get lb -o wide' 2> /dev/null +echo "******************************************************************************" +echo -e "\nEP List" +echo "******************************************************************************" +vagrant ssh loxilb -c 'sudo docker exec -it loxilb loxicmd get ep -o wide' 2> /dev/null +echo "******************************************************************************" + +echo -e "\nTEST RESULTS" +echo "******************************************************************************" +mode=( "default" "onearm" "fullnat" ) +tcp_port=( 55002 56002 57002 ) +udp_port=( 55003 56003 57003 ) +sctp_port=( 55004 56004 57004 ) +code=0 +for ((i=0;i<=2;i++)); do +out=$(curl -s --connect-timeout 10 http://$extIP:${tcp_port[i]}) +if [[ ${out} == *"Welcome to nginx"* ]]; then + echo -e "K8s-calico-ipvs TCP\t(${mode[i]})\t[OK]" +else + echo -e "K8s-calico-ipvs TCP\t(${mode[i]})\t[FAILED]" + ## Dump some debug info + echo "llb1 lb-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 loxicmd get lb -o wide' 2> /dev/null + echo "llb1 route-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 ip route' 2> /dev/null + code=1 +fi + +out=$(timeout 5 ../common/udp_client $extIP ${udp_port[i]}) +if [[ ${out} == *"Client"* ]]; then + echo -e "K8s-calico-ipvs UDP\t(${mode[i]})\t[OK]" +else + echo -e "K8s-calico-ipvs UDP\t(${mode[i]})\t[FAILED]" + ## Dump some debug info + echo "llb1 lb-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 loxicmd get lb -o wide' 2> /dev/null + echo "llb1 route-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 ip route' 2> /dev/null + code=1 +fi + +if [[ ${mode[i]} == "fullnat" ]]; then + sctp_darn -H 192.168.90.1 -h $extIP -p ${sctp_port[i]} -s < input > output + sleep 5 +exp="New connection, peer addresses +123.123.123.1:57004 +124.124.124.1:57004 +125.125.125.1:57004" + + res=`cat output | grep -A 3 "New connection, peer addresses"` + sudo rm -rf output + if [[ "$res" == "$exp" ]]; then + echo -e "K8s-calico-ipvs SCTP\t(${mode[i]})\t[OK]" + else + echo -e "K8s-calico-ipvs SCTP\t(${mode[i]})\t[FAILED]" + fi +else + out=$(timeout 5 ../common/sctp_client 192.168.90.1 34951 $extIP ${sctp_port[i]}) + if [[ ${out} == *"server1"* ]]; then + echo -e "K8s-calico-ipvs SCTP\t(${mode[i]})\t[OK]" + else + echo -e "K8s-calico-ipvs SCTP\t(${mode[i]})\t[FAILED]" + ## Dump some debug info + echo "llb1 lb-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 loxicmd get lb -o wide' 2> /dev/null + echo "llb1 route-info" + vagrant ssh loxilb -c 'sudo docker exec -it llb1 ip route' 2> /dev/null + code=1 + fi +fi +done +exit $code diff --git a/cicd/k8s-calico-ipvs/yaml/kube-loxilb.yml b/cicd/k8s-calico-ipvs/yaml/kube-loxilb.yml new file mode 100644 index 000000000..3d8a07bbf --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/kube-loxilb.yml @@ -0,0 +1,134 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kube-loxilb + namespace: kube-system +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: kube-loxilb +rules: + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - watch + - list + - patch + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - watch + - list + - patch + - apiGroups: + - "" + resources: + - endpoints + - services + - services/status + verbs: + - get + - watch + - list + - patch + - update + - apiGroups: + - discovery.k8s.io + resources: + - endpointslices + verbs: + - get + - watch + - list + - apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create + - apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: kube-loxilb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kube-loxilb +subjects: + - kind: ServiceAccount + name: kube-loxilb + namespace: kube-system +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kube-loxilb + namespace: kube-system + labels: + app: loxilb +spec: + replicas: 1 + selector: + matchLabels: + app: loxilb + template: + metadata: + labels: + app: loxilb + spec: + hostNetwork: true + tolerations: + - effect: NoSchedule + operator: Exists + # Mark the pod as a critical add-on for rescheduling. + - key: CriticalAddonsOnly + operator: Exists + - effect: NoExecute + operator: Exists + priorityClassName: system-node-critical + serviceAccountName: kube-loxilb + terminationGracePeriodSeconds: 0 + containers: + - name: kube-loxilb + image: ghcr.io/loxilb-io/kube-loxilb:latest + imagePullPolicy: Always + command: + - /bin/kube-loxilb + args: + - --loxiURL=http://192.168.80.9:11111 + - --externalCIDR=123.123.123.1/24 + - --externalSecondaryCIDRs=124.124.124.1/24,125.125.125.1/24 + #- --monitor + #- --setBGP=64511 + #- --extBGPPeers=50.50.50.1:65101,51.51.51.1:65102 + - --setRoles=9.9.9.9 + #- --monitor + #- --setBGP + #- --setLBMode=1 + #- --config=/opt/loxilb/agent/kube-loxilb.conf + resources: + requests: + cpu: "100m" + memory: "50Mi" + limits: + cpu: "100m" + memory: "50Mi" + securityContext: + privileged: true + capabilities: + add: ["NET_ADMIN", "NET_RAW"] diff --git a/cicd/k8s-calico-ipvs/yaml/kubeadm-config.yaml b/cicd/k8s-calico-ipvs/yaml/kubeadm-config.yaml new file mode 100644 index 000000000..4acccfac8 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/kubeadm-config.yaml @@ -0,0 +1,69 @@ +apiVersion: kubeadm.k8s.io/v1beta3 +bootstrapTokens: +- groups: + - system:bootstrappers:kubeadm:default-node-token + ttl: 24h0m0s + usages: + - signing + - authentication +kind: InitConfiguration +localAPIEndpoint: + advertiseAddress: 192.168.80.10 + bindPort: 6443 +nodeRegistration: + imagePullPolicy: IfNotPresent + name: master + taints: null +--- +apiVersion: kubeadm.k8s.io/v1beta3 +certificatesDir: /etc/kubernetes/pki +kind: ClusterConfiguration +apiServer: + timeoutForControlPlane: 4m0s + certSANs: + - 192.168.80.10 +controlPlaneEndpoint: 192.168.80.10:6443 +clusterName: kubernetes +controllerManager: {} +dns: {} +etcd: + local: + dataDir: /var/lib/etcd +imageRepository: registry.k8s.io +kubernetesVersion: v1.27.5 +networking: + dnsDomain: cluster.local + podSubnet: 172.16.1.0/16 + serviceSubnet: 172.17.1.0/18 +scheduler: {} +--- +apiVersion: kubeproxy.config.k8s.io/v1alpha1 +bindAddress: 0.0.0.0 +clientConnection: + acceptContentTypes: "" + burst: 10 + contentType: application/vnd.kubernetes.protobuf + kubeconfig: /var/lib/kube-proxy/kubeconfig.conf + qps: 5 +clusterCIDR: "" +configSyncPeriod: 15m0s +#featureGates: "SupportIPVSProxyMode=true" +mode: ipvs +enableProfiling: false +healthzBindAddress: 0.0.0.0:10256 +hostnameOverride: "" +iptables: + masqueradeAll: false + masqueradeBit: 14 + minSyncPeriod: 0s + syncPeriod: 30s +ipvs: + excludeCIDRs: null + minSyncPeriod: 0s + scheduler: "" + syncPeriod: 30s +kind: KubeProxyConfiguration +metricsBindAddress: 127.0.0.1:10249 +nodePortAddresses: null +oomScoreAdj: -999 +portRange: "" diff --git a/cicd/k8s-calico-ipvs/yaml/sctp.yml b/cicd/k8s-calico-ipvs/yaml/sctp.yml new file mode 100644 index 000000000..c9a7d4afd --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/sctp.yml @@ -0,0 +1,41 @@ +apiVersion: v1 +kind: Service +metadata: + name: sctp-lb-default + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "default" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: sctp-default-test + ports: + - port: 55004 + protocol: SCTP + targetPort: 9999 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: sctp-default-test + labels: + what: sctp-default-test +spec: + containers: + - name: sctp-default-test + image: ghcr.io/loxilb-io/alpine-socat:latest + command: [ "sh", "-c"] + args: + - while true; do + socat -v -T2 sctp-l:9999,reuseaddr,fork system:"echo 'server1'; cat"; + sleep 20; + done; + ports: + - containerPort: 9999 + env: + - name: MY_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP diff --git a/cicd/k8s-calico-ipvs/yaml/sctp_fullnat.yml b/cicd/k8s-calico-ipvs/yaml/sctp_fullnat.yml new file mode 100644 index 000000000..6b43037a5 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/sctp_fullnat.yml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Service +metadata: + name: sctp-lb-fullnat + annotations: + loxilb.io/num-secondary-networks: "2" + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "fullnat" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: sctp-fullnat-test + ports: + - port: 57004 + protocol: SCTP + targetPort: 9999 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: sctp-fullnat-test + labels: + what: sctp-fullnat-test +spec: + containers: + - name: sctp-fullnat-test + image: loxilbio/sctp-darn:latest + imagePullPolicy: Always + #command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 6 ; done"] + command: ["sctp_darn","-H", "0.0.0.0","-P", "9999", "-l"] + ports: + - containerPort: 9999 + env: + - name: MY_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP diff --git a/cicd/k8s-calico-ipvs/yaml/sctp_onearm.yml b/cicd/k8s-calico-ipvs/yaml/sctp_onearm.yml new file mode 100644 index 000000000..b4b736962 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/sctp_onearm.yml @@ -0,0 +1,41 @@ +apiVersion: v1 +kind: Service +metadata: + name: sctp-lb-onearm + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "onearm" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: sctp-onearm-test + ports: + - port: 56004 + protocol: SCTP + targetPort: 9999 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: sctp-onearm-test + labels: + what: sctp-onearm-test +spec: + containers: + - name: sctp-onearm-test + image: ghcr.io/loxilb-io/alpine-socat:latest + command: [ "sh", "-c"] + args: + - while true; do + socat -v -T2 sctp-l:9999,reuseaddr,fork system:"echo 'server1'; cat"; + sleep 20; + done; + ports: + - containerPort: 9999 + env: + - name: MY_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP diff --git a/cicd/k8s-calico-ipvs/yaml/settings.yaml b/cicd/k8s-calico-ipvs/yaml/settings.yaml new file mode 100644 index 000000000..ffa7fe692 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/settings.yaml @@ -0,0 +1,44 @@ +--- +# cluster_name is used to group the nodes in a folder within VirtualBox: +cluster_name: Kubernetes Cluster +# Uncomment to set environment variables for services such as crio and kubelet. +# For example, configure the cluster to pull images via a proxy. +# environment: | +# HTTP_PROXY=http://my-proxy:8000 +# HTTPS_PROXY=http://my-proxy:8000 +# NO_PROXY=127.0.0.1,localhost,master-node,node01,node02,node03 +# All IPs/CIDRs should be private and allowed in /etc/vbox/networks.conf. +network: + iloxilb_ip: 192.168.80.9 + oloxilb_ip: 192.168.90.9 + # Worker IPs are simply incremented from the control IP. + control_ip: 192.168.80.10 + dns_servers: + - 8.8.8.8 + - 1.1.1.1 + pod_cidr: 172.16.1.0/16 + service_cidr: 172.17.1.0/18 +nodes: + control: + cpu: 2 + memory: 4096 + workers: + count: 2 + cpu: 1 + memory: 2048 +# Mount additional shared folders from the host into each virtual machine. +# Note that the project directory is automatically mounted at /vagrant. +# shared_folders: +# - host_path: ../images +# vm_path: /vagrant/images +software: + loxilb: + box: + name: sysnet4admin/Ubuntu-k8s + version: 0.7.1 + cluster: + box: bento/ubuntu-22.04 + calico: 3.26.0 + # To skip the dashboard installation, set its version to an empty value or comment it out: + kubernetes: 1.27.1-00 + os: xUbuntu_22.04 diff --git a/cicd/k8s-calico-ipvs/yaml/tcp.yml b/cicd/k8s-calico-ipvs/yaml/tcp.yml new file mode 100644 index 000000000..8c8983403 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/tcp.yml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Service +metadata: + name: tcp-lb-default + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "default" +spec: + externalTrafficPolicy: Local + loadBalancerClass: loxilb.io/loxilb + selector: + what: tcp-default-test + ports: + - port: 55002 + targetPort: 80 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: tcp-default-test + labels: + what: tcp-default-test +spec: + containers: + - name: tcp-default-test + image: ghcr.io/loxilb-io/nginx:stable + ports: + - containerPort: 80 diff --git a/cicd/k8s-calico-ipvs/yaml/tcp_fullnat.yml b/cicd/k8s-calico-ipvs/yaml/tcp_fullnat.yml new file mode 100644 index 000000000..3303ac35e --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/tcp_fullnat.yml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Service +metadata: + name: tcp-lb-fullnat + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "fullnat" +spec: + externalTrafficPolicy: Local + loadBalancerClass: loxilb.io/loxilb + selector: + what: tcp-fullnat-test + ports: + - port: 57002 + targetPort: 80 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: tcp-fullnat-test + labels: + what: tcp-fullnat-test +spec: + containers: + - name: tcp-fullnat-test + image: ghcr.io/loxilb-io/nginx:stable + ports: + - containerPort: 80 diff --git a/cicd/k8s-calico-ipvs/yaml/tcp_onearm.yml b/cicd/k8s-calico-ipvs/yaml/tcp_onearm.yml new file mode 100644 index 000000000..b3d345483 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/tcp_onearm.yml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Service +metadata: + name: tcp-lb-onearm + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "onearm" +spec: + externalTrafficPolicy: Local + loadBalancerClass: loxilb.io/loxilb + selector: + what: tcp-onearm-test + ports: + - port: 56002 + targetPort: 80 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: tcp-onearm-test + labels: + what: tcp-onearm-test +spec: + containers: + - name: tcp-onearm-test + image: ghcr.io/loxilb-io/nginx:stable + ports: + - containerPort: 80 diff --git a/cicd/k8s-calico-ipvs/yaml/udp.yml b/cicd/k8s-calico-ipvs/yaml/udp.yml new file mode 100644 index 000000000..ac6ef997d --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/udp.yml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Service +metadata: + name: udp-lb-default + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "default" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: udp-default-test + ports: + - port: 55003 + protocol: UDP + targetPort: 33333 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: udp-default-test + labels: + what: udp-default-test +spec: + containers: + - name: udp-default-test + image: ghcr.io/loxilb-io/udp-echo:latest + ports: + - containerPort: 33333 diff --git a/cicd/k8s-calico-ipvs/yaml/udp_fullnat.yml b/cicd/k8s-calico-ipvs/yaml/udp_fullnat.yml new file mode 100644 index 000000000..67b729019 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/udp_fullnat.yml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Service +metadata: + name: udp-lb-fullnat + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "fullnat" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: udp-fullnat-test + ports: + - port: 57003 + protocol: UDP + targetPort: 33333 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: udp-fullnat-test + labels: + what: udp-fullnat-test +spec: + containers: + - name: udp-fullnat-test + image: ghcr.io/loxilb-io/udp-echo:latest + ports: + - containerPort: 33333 diff --git a/cicd/k8s-calico-ipvs/yaml/udp_onearm.yml b/cicd/k8s-calico-ipvs/yaml/udp_onearm.yml new file mode 100644 index 000000000..833187e73 --- /dev/null +++ b/cicd/k8s-calico-ipvs/yaml/udp_onearm.yml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Service +metadata: + name: udp-lb-onearm + annotations: + loxilb.io/liveness: "yes" + loxilb.io/lbmode: "onearm" +spec: + loadBalancerClass: loxilb.io/loxilb + externalTrafficPolicy: Local + selector: + what: udp-onearm-test + ports: + - port: 56003 + protocol: UDP + targetPort: 33333 + type: LoadBalancer +--- +apiVersion: v1 +kind: Pod +metadata: + name: udp-onearm-test + labels: + what: udp-onearm-test +spec: + containers: + - name: udp-onearm-test + image: ghcr.io/loxilb-io/udp-echo:latest + ports: + - containerPort: 33333 From 84af802cdff110bfe1973f7e74cd5f505072fc49 Mon Sep 17 00:00:00 2001 From: TrekkieCoder <111065900+TrekkieCoder@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:50:46 +0900 Subject: [PATCH 2/4] Create k8s-calico-ipvs.yml --- .github/workflows/k8s-calico-ipvs.yml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/k8s-calico-ipvs.yml diff --git a/.github/workflows/k8s-calico-ipvs.yml b/.github/workflows/k8s-calico-ipvs.yml new file mode 100644 index 000000000..85abd82db --- /dev/null +++ b/.github/workflows/k8s-calico-ipvs.yml @@ -0,0 +1,36 @@ +name: K8s-Calico-Cluster-IPVS-Sanity-CI +on: + #schedule: + # Runs "At 13:00 UTC every day-of-week" + #- cron: '0 13 * * *' + workflow_dispatch: + inputs: + testName: + description: 'Test Run-Name' + required: true + default: 'k8s-calico-cluster-ipvs' +jobs: + test-runner: + name: k8s-calico-cluster-ipvs-sanity + runs-on: self-hosted + if: github.repository == 'loxilb-io/loxilb' + && github.event.inputs.tagName == '' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Run the test + run: | + cd cicd/k8s-calico-ipvs + ./config.sh + ./validation.sh + cd - + + - name: Clean test-bed + if: success() || failure() + run: | + cd cicd/k8s-calico-ipvs || true + ./rmconfig.sh + cd - From 74b261ea35615fa88ea1765d45ffb4565252830c Mon Sep 17 00:00:00 2001 From: TrekkieCoder <111065900+TrekkieCoder@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:59:18 +0900 Subject: [PATCH 3/4] Update k8s-calico-ipvs.yml --- .github/workflows/k8s-calico-ipvs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/k8s-calico-ipvs.yml b/.github/workflows/k8s-calico-ipvs.yml index 85abd82db..d74284aee 100644 --- a/.github/workflows/k8s-calico-ipvs.yml +++ b/.github/workflows/k8s-calico-ipvs.yml @@ -13,7 +13,7 @@ jobs: test-runner: name: k8s-calico-cluster-ipvs-sanity runs-on: self-hosted - if: github.repository == 'loxilb-io/loxilb' + if: github.repository == 'TrekkieCoder/loxilb' && github.event.inputs.tagName == '' steps: - name: Checkout From 1b3cc7222fd18dd70a3e52ead4384da2c8dff4bd Mon Sep 17 00:00:00 2001 From: TrekkieCoder <111065900+TrekkieCoder@users.noreply.github.com> Date: Fri, 1 Sep 2023 14:22:49 +0900 Subject: [PATCH 4/4] Update k8s-calico-ipvs.yml --- .github/workflows/k8s-calico-ipvs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/k8s-calico-ipvs.yml b/.github/workflows/k8s-calico-ipvs.yml index d74284aee..85abd82db 100644 --- a/.github/workflows/k8s-calico-ipvs.yml +++ b/.github/workflows/k8s-calico-ipvs.yml @@ -13,7 +13,7 @@ jobs: test-runner: name: k8s-calico-cluster-ipvs-sanity runs-on: self-hosted - if: github.repository == 'TrekkieCoder/loxilb' + if: github.repository == 'loxilb-io/loxilb' && github.event.inputs.tagName == '' steps: - name: Checkout