Haproxy installation CENTOS 7

haproxy installation and configuration centos 7

yum install -y haproxy


##Ignore VIP
echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl .conf
sysctl
-p

cat> /etc/haproxy/haproxy.cfg << EOF
global
log
127.0.0.1 local3 info
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect
5000
timeout client
50000
timeout server
50000
frontend k8s_api
mode tcp
bind
*:16443
default_backend k8s_api

backend k8s_api
mode tcp
balance roundrobin
server k8s150
192.168.0.150:6443 check
server k8s151
192.168.0.151:6443 check

listen stats
mode http
bind
0.0.0.0:1080
stats enable
stats hide
-version
stats uri
/stats
stats realm Haproxy\ Statistics
stats auth admin:admin123
stats admin
if TRUE
EOF

systemctl enable haproxy.service
systemctl restart haproxy.service
systemctl status haproxy.service
netstat
-lnt | grep -E "16443|1080"

< pre>yum instally haproxy

##Ignore VIP

echo net.ipv4.ip_nonlocal_bind = 1 >>/etc/sysctl .conf

sysctl
p

cat> /etc/haproxy/haproxy.cfg << EOF

global

log
127.0.0.1 local3 info

chroot /var/lib/haproxy

user haproxy

group haproxy

daemon

defaults

log global

mode http

option httplog

option dontlognull

timeout connect
5000

timeout client
50000

timeout server
50000

frontend k8s_api

mode tcp

bind
*:16443

default_backend k8s_api

backend k8s_api

mode tcp

balance roundrobin

server k8s150 192.168.0.150:6443 check

server k8s151
192.168.0.151:6443 check

listen stats

mode http

bind 0.0.0.0:1080

stats enable

stats hide
version

stats uri
/stats

stats realm Haproxy\ Statistics

stats auth admin:admin123

stats admin
if TRUE

EOF

systemctl enable haproxy.service

systemctl restart haproxy.service

systemctl status haproxy.service

netstat -lnt | grep -E 16443|1080

Leave a Comment

Your email address will not be published.