-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to command SW NLB-HAProxy
- Loading branch information
1 parent
3e1444f
commit 4e10baa
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |