diff --git a/cicd/k3s-sharding/input b/cicd/k3s-sharding/input new file mode 100644 index 000000000..6fb66a5e2 --- /dev/null +++ b/cicd/k3s-sharding/input @@ -0,0 +1,6 @@ + + + + + + diff --git a/cicd/k3s-sharding/lbconfig.txt b/cicd/k3s-sharding/lbconfig.txt new file mode 100644 index 000000000..f96094054 --- /dev/null +++ b/cicd/k3s-sharding/lbconfig.txt @@ -0,0 +1,41 @@ +{ + "lbAttr":[ + { + "serviceArguments":{ + "externalIP":"192.168.80.80", + "port":6443, + "protocol":"tcp", + "sel":0, + "mode":2, + "BGP":false, + "Monitor":true, + "inactiveTimeOut":240, + "block":0 + }, + "secondaryIPs":null, + "endpoints":[ + { + "endpointIP":"192.168.80.10", + "targetPort":6443, + "weight":1, + "state":"active", + "counter":"" + }, + { + "endpointIP":"192.168.80.11", + "targetPort":6443, + "weight":1, + "state":"active", + "counter":"" + }, + { + "endpointIP":"192.168.80.12", + "targetPort":6443, + "weight":1, + "state":"active", + "counter":"" + } + ] + } + ] +} diff --git a/cicd/k3s-sharding/loxilb.yml b/cicd/k3s-sharding/loxilb.yml new file mode 100644 index 000000000..6869f969f --- /dev/null +++ b/cicd/k3s-sharding/loxilb.yml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: loxilb-lb + namespace: kube-system +spec: + selector: + matchLabels: + app: loxilb-app + template: + metadata: + name: loxilb-lb + labels: + app: loxilb-app + spec: + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + tolerations: + - key: "node-role.kubernetes.io/master" + operator: Exists + - key: "node-role.kubernetes.io/control-plane" + operator: Exists + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "node-role.kubernetes.io/master" + operator: Exists + - key: "node-role.kubernetes.io/control-plane" + operator: Exists + volumes: + - name: hllb + hostPath: + path: /etc/loxilb + type: DirectoryOrCreate + containers: + - name: loxilb-app + image: "ghcr.io/loxilb-io/loxilb:latest" + imagePullPolicy: Always + command: + - /root/loxilb-io/loxilb/loxilb + args: + - --egr-hooks + - --blacklist=cni[0-9a-z]|veth.|flannel.|cali.|tunl.|vxlan[.]calico + volumeMounts: + - name: hllb + mountPath: /etc/loxilb + ports: + - containerPort: 11111 + - containerPort: 179 + securityContext: + privileged: true + capabilities: + add: + - SYS_ADMIN +--- +apiVersion: v1 +kind: Service +metadata: + name: loxilb-lb-service + namespace: kube-system +spec: + clusterIP: None + selector: + app: loxilb-app + ports: + - name: loxilb-app + port: 11111 + targetPort: 11111 + protocol: TCP diff --git a/cicd/k3s-sharding/master1.sh b/cicd/k3s-sharding/master1.sh new file mode 100755 index 000000000..a70eb09de --- /dev/null +++ b/cicd/k3s-sharding/master1.sh @@ -0,0 +1,13 @@ +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.80 --disable-cloud-controller --flannel-iface=eth1 +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 +cp /etc/rancher/k3s/k3s.yaml /vagrant/k3s.yaml +sed -i -e "s/127.0.0.1/192.168.80.80/g" /vagrant/k3s.yaml +sudo mkdir -p /etc/loxilb +sudo cp /vagrant/lbconfig.txt /etc/loxilb/ +sudo cp /vagrant/EPconfig.txt /etc/loxilb/ +/vagrant/wait_ready.sh diff --git a/cicd/k3s-sharding/master2.sh b/cicd/k3s-sharding/master2.sh new file mode 100755 index 000000000..354d86a52 --- /dev/null +++ b/cicd/k3s-sharding/master2.sh @@ -0,0 +1,13 @@ +sudo su +export WORKER_ADDR=$(ip a |grep global | grep -v '10.0.2.15' | grep '192.168.80' | awk '{print $2}' | cut -f1 -d '/') +export MASTER_ADDR=$(cat /vagrant/master-ip) +export NODE_TOKEN=$(cat /vagrant/node-token) +sudo mkdir -p /etc/loxilb +sudo cp /vagrant/lbconfig.txt /etc/loxilb/ +sudo cp /vagrant/EPconfig.txt /etc/loxilb/ +#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.80 -t ${NODE_TOKEN} --flannel-iface=eth1 +curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - +#sudo kubectl apply -f /vagrant/loxilb.yml +#sudo kubectl apply -f /vagrant/kube-loxilb.yml +/vagrant/wait_ready.sh diff --git a/cicd/k3s-sharding/master3.sh b/cicd/k3s-sharding/master3.sh new file mode 100755 index 000000000..d05e74d66 --- /dev/null +++ b/cicd/k3s-sharding/master3.sh @@ -0,0 +1,13 @@ +sudo su +export WORKER_ADDR=$(ip a |grep global | grep -v '10.0.2.15' | grep '192.168.80' | awk '{print $2}' | cut -f1 -d '/') +export MASTER_ADDR=$(cat /vagrant/master-ip) +export NODE_TOKEN=$(cat /vagrant/node-token) +sudo mkdir -p /etc/loxilb +sudo cp /vagrant/lbconfig.txt /etc/loxilb/ +sudo cp /vagrant/EPconfig.txt /etc/loxilb/ +#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.12 external-hostname=192.168.80.12 --node-external-ip=192.168.80.80 -t ${NODE_TOKEN} --flannel-iface=eth1 +curl -sfL https://github.com/loxilb-io/loxilb-ebpf/raw/main/kprobe/install.sh | sh - +sudo kubectl apply -f /vagrant/loxilb.yml +sudo kubectl apply -f /vagrant/kube-loxilb.yml +/vagrant/wait_ready.sh