Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to command SW NLB-HAProxy #1224

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scripts/nlb/addTargetNode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

nodeId=${1:-vm}
nodeIp=${2:-127.0.0.1}
targetPort=${3:-80}

## haproxy can be replaced

echo " server ${nodeId} ${nodeIp}:${targetPort} check" | sudo tee -a /etc/haproxy/haproxy.cfg

## show config
cat /etc/haproxy/haproxy.cfg
6 changes: 6 additions & 0 deletions scripts/nlb/applyConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

## haproxy can be replaced

sudo systemctl restart haproxy
cat /etc/haproxy/haproxy.cfg
41 changes: 41 additions & 0 deletions scripts/nlb/deployNlb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

mcisId=${1:-mcis}
listenMode=${2:-tcp}
listenPort=${3:-80}
balanceAlgo=${4:-roundrobin}

## haproxy can be replaced
sudo apt update > /dev/null
sudo apt install haproxy -y > /dev/null
sudo systemctl enable haproxy
haproxy -v

## show config
cat /etc/haproxy/haproxy.cfg

echo "
## define admin page for statistics dashboard
listen admin
bind *:9000
mode http
stats enable
stats refresh 10s
stats uri /
stats auth default:default" | sudo tee -a /etc/haproxy/haproxy.cfg

echo "
## define frontend
frontend ${mcisId}.frontend
bind *:$listenPort
mode $listenMode
default_backend ${mcisId}.backend
option forwardfor" | sudo tee -a /etc/haproxy/haproxy.cfg

echo "
## define backend
backend ${mcisId}.backend
balance ${balanceAlgo}" | sudo tee -a /etc/haproxy/haproxy.cfg

## show config
cat /etc/haproxy/haproxy.cfg