kubeasz/roles/ex-lb/templates/haproxy.cfg.j2

65 lines
2.2 KiB
Plaintext
Raw Normal View History

2019-02-07 15:10:49 +08:00
global
2019-05-30 21:37:01 +08:00
log /dev/log local1 warning
2019-02-07 15:10:49 +08:00
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
nbproc 1
defaults
log global
2019-05-30 21:37:01 +08:00
timeout connect 5s
2019-02-07 15:10:49 +08:00
timeout client 10m
timeout server 10m
2019-05-30 21:37:01 +08:00
listen kube-master
bind 0.0.0.0:{{ EX_APISERVER_PORT }}
mode tcp
option tcplog
option dontlognull
option dontlog-normal
balance {{ BALANCE_ALG }}
{% for host in groups['kube-master'] %}
server {{ host }} {{ host }}:6443 check inter 5s fall 2 rise 2 weight 1
{% endfor %}
2019-02-07 15:10:49 +08:00
2019-05-30 21:37:01 +08:00
{% if INGRESS_NODEPORT_LB == "yes" %}
2019-02-07 15:10:49 +08:00
listen ingress-node
bind 0.0.0.0:80
mode tcp
option tcplog
2019-05-30 21:37:01 +08:00
option dontlognull
option dontlog-normal
2019-02-07 15:10:49 +08:00
balance {{ BALANCE_ALG }}
2019-05-30 21:37:01 +08:00
{% if groups['kube-node']|length > 3 %}
server {{ groups['kube-node'][0] }} {{ groups['kube-node'][0] }}:23456 check inter 5s fall 2 rise 2 weight 1
server {{ groups['kube-node'][1] }} {{ groups['kube-node'][1] }}:23456 check inter 5s fall 2 rise 2 weight 1
server {{ groups['kube-node'][2] }} {{ groups['kube-node'][2] }}:23456 check inter 5s fall 2 rise 2 weight 1
{% else %}
2019-02-07 15:10:49 +08:00
{% for host in groups['kube-node'] %}
2019-05-30 21:37:01 +08:00
server {{ host }} {{ host }}:23456 check inter 5s fall 2 rise 2 weight 1
2019-02-07 15:10:49 +08:00
{% endfor %}
{% endif %}
2019-05-30 21:37:01 +08:00
{% endif %}
2019-02-07 15:10:49 +08:00
2019-05-30 21:37:01 +08:00
{% if INGRESS_TLS_NODEPORT_LB == "yes" %}
2019-02-07 15:10:49 +08:00
listen ingress-node-tls
bind 0.0.0.0:443
mode tcp
option tcplog
2019-05-30 21:37:01 +08:00
option dontlognull
option dontlog-normal
2019-02-07 15:10:49 +08:00
balance {{ BALANCE_ALG }}
2019-05-30 21:37:01 +08:00
{% if groups['kube-node']|length > 3 %}
server {{ groups['kube-node'][0] }} {{ groups['kube-node'][0] }}:23457 check inter 5s fall 2 rise 2 weight 1
server {{ groups['kube-node'][1] }} {{ groups['kube-node'][1] }}:23457 check inter 5s fall 2 rise 2 weight 1
server {{ groups['kube-node'][2] }} {{ groups['kube-node'][2] }}:23457 check inter 5s fall 2 rise 2 weight 1
{% else %}
2019-02-07 15:10:49 +08:00
{% for host in groups['kube-node'] %}
2019-06-09 10:58:01 +08:00
server {{ host }} {{ host }}:23457 check inter 5s fall 2 rise 2 weight 1
2019-02-07 15:10:49 +08:00
{% endfor %}
{% endif %}
2019-05-30 21:37:01 +08:00
{% endif %}