Skip to content

Commit

Permalink
Add scripts to command SW NLB-HAProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Oct 20, 2022
1 parent 3e1444f commit 4e10baa
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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

0 comments on commit 4e10baa

Please sign in to comment.