diff --git a/examples/loadbalancertest/config.yaml b/examples/loadbalancertest/config.yaml new file mode 100644 index 0000000..f6c5e4f --- /dev/null +++ b/examples/loadbalancertest/config.yaml @@ -0,0 +1,38 @@ +healthcheck_addr: "10.0.1.10:9000" + +iperf_addr: "10.0.1.10:5201" + +backends: + - id: "srv-1" + ip: "10.0.1.11:8081" + - id: "srv-2" + ip: "10.0.1.12:8082" + - id: "srv-3" + ip: "10.0.1.13:8083" + - id: "srv-4" + ip: "10.0.1.14:8084" + +clusters: + main-api: + - "srv-1" + - "srv-2" + priority-api: + - "srv-3" + - "srv-4" + +rules: + - clients: + - "0.0.0.0/0:8080" + targets: + - "main-api" + strategy: + type: "RoundRobin" + + - clients: + - "10.0.0.0/24:8080" + - "10.0.0.0/24:25565" + targets: + - "main-api" + - "priority-api" + strategy: + type: "RoundRobin" diff --git a/examples/loadbalancertest/docker-compose.yml b/examples/loadbalancertest/docker-compose.yml new file mode 100644 index 0000000..5a25b9c --- /dev/null +++ b/examples/loadbalancertest/docker-compose.yml @@ -0,0 +1,110 @@ +services: + load-balancer: + image: enginewhy + container_name: load-balancer + tty: true + cap_add: + - NET_ADMIN + - SYS_ADMIN + volumes: + - ./config.yaml:/enginewhy/config.yaml + networks: + net_1: + ipv4_address: 10.0.1.10 + net_2: + ipv4_address: 10.0.0.10 + net_3: + ipv4_address: 10.0.2.10 + + srv-1: + image: nicolaka/netshoot + container_name: srv-1 + tty: true + command: ["python3", "-m", "http.server", "8081", "--directory", "/root/www"] + networks: + net_1: + ipv4_address: 10.0.1.11 + ports: + - "8081:8081" + volumes: + - ./srv1:/root/www + cap_add: [ NET_ADMIN ] + + srv-2: + image: nicolaka/netshoot + container_name: srv-2 + tty: true + command: ["python3", "-m", "http.server", "8082", "--directory", "/root/www"] + networks: + net_1: + ipv4_address: 10.0.1.12 + ports: + - "8082:8082" + volumes: + - ./srv2:/root/www + cap_add: [ NET_ADMIN ] + + srv-3: + image: nicolaka/netshoot + container_name: srv-3 + tty: true + command: ["python3", "-m", "http.server", "8083", "--directory", "/root/www"] + networks: + net_1: + ipv4_address: 10.0.1.13 + ports: + - "8083:8083" + volumes: + - ./srv3:/root/www + cap_add: [ NET_ADMIN ] + + srv-4: + image: nicolaka/netshoot + container_name: srv-4 + tty: true + command: ["python3", "-m", "http.server", "8084", "--directory", "/root/www"] + networks: + net_1: + ipv4_address: 10.0.1.14 + ports: + - "8084:8084" + volumes: + - ./srv4:/root/www + cap_add: [ NET_ADMIN ] + + client-net2: + image: nicolaka/netshoot + container_name: client-net2 + tty: true + networks: + net_2: + ipv4_address: 10.0.0.11 + cap_add: [ NET_ADMIN ] + + client-net3: + image: nicolaka/netshoot + container_name: client-net3 + tty: true + networks: + net_3: + ipv4_address: 10.0.2.11 + cap_add: [ NET_ADMIN ] + +networks: + net_1: + driver: bridge + ipam: + config: + - subnet: 10.0.1.0/24 + + net_2: + driver: bridge + ipam: + config: + - subnet: 10.0.0.0/24 + + net_3: + driver: bridge + ipam: + config: + - subnet: 10.0.2.0/24 diff --git a/examples/loadbalancertest/srv1/index.html b/examples/loadbalancertest/srv1/index.html new file mode 100644 index 0000000..9fa14cb --- /dev/null +++ b/examples/loadbalancertest/srv1/index.html @@ -0,0 +1 @@ +Hello from server 1! diff --git a/examples/loadbalancertest/srv2/index.html b/examples/loadbalancertest/srv2/index.html new file mode 100644 index 0000000..a968e39 --- /dev/null +++ b/examples/loadbalancertest/srv2/index.html @@ -0,0 +1 @@ +Hello from server 2! diff --git a/examples/loadbalancertest/srv3/index.html b/examples/loadbalancertest/srv3/index.html new file mode 100644 index 0000000..109cca0 --- /dev/null +++ b/examples/loadbalancertest/srv3/index.html @@ -0,0 +1 @@ +Hello from server 3! diff --git a/examples/loadbalancertest/srv4/index.html b/examples/loadbalancertest/srv4/index.html new file mode 100644 index 0000000..821a103 --- /dev/null +++ b/examples/loadbalancertest/srv4/index.html @@ -0,0 +1 @@ +Hello from server 4!