Skip to content

Commit

Permalink
更新haproxy负载均衡算法配置
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Jul 13, 2018
1 parent 6afcd95 commit 870d51e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/hosts.allinone.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#集群部署模式:allinone, single-master, multi-master
DEPLOY_MODE=allinone

#集群主版本号,目前支持: v1.8, v1.9, v1.10
#集群主版本号,目前支持: v1.8, v1.9, v1.10,v1.11
K8S_VER="v1.10"

#集群 MASTER IP
Expand Down
5 changes: 2 additions & 3 deletions example/hosts.m-masters.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
192.168.1.1
192.168.1.2

# 负载均衡至少两个节点,安装 haproxy+keepalived
# 如果是公有云环境请优先使用云上负载均衡,lb组留空
# 负载均衡有且仅有两个节点,安装 haproxy+keepalived
[lb]
192.168.1.1 LB_IF="eth0" LB_ROLE=backup # 注意根据实际使用网卡设置 LB_IF变量
192.168.1.2 LB_IF="eth0" LB_ROLE=master
Expand All @@ -39,7 +38,7 @@
#集群部署模式:allinone, single-master, multi-master
DEPLOY_MODE=multi-master

#集群主版本号,目前支持: v1.8, v1.9, v1.10
#集群主版本号,目前支持: v1.8, v1.9, v1.10,v1.11
K8S_VER="v1.10"

# 集群 MASTER IP即 LB节点VIP地址,为区别与默认apiserver端口,设置VIP监听的服务端口8443
Expand Down
6 changes: 2 additions & 4 deletions example/hosts.s-master.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# etcd集群请提供如下NODE_NAME,请注意etcd集群必须是1,3,5,7...奇数个节点
[etcd]
192.168.1.1 NODE_NAME=etcd1
192.168.1.2 NODE_NAME=etcd2
192.168.1.3 NODE_NAME=etcd3

[kube-master]
192.168.1.1
Expand All @@ -28,8 +26,8 @@
#集群部署模式:allinone, single-master, multi-master
DEPLOY_MODE=single-master

#集群主版本号,目前支持: v1.8, v1.9, v1.10
K8S_VER="v1.10"
#集群主版本号,目前支持: v1.8, v1.9, v1.10,v1.11
K8S_VER="v1.11"

#集群 MASTER IP
MASTER_IP="192.168.1.1"
Expand Down
13 changes: 10 additions & 3 deletions roles/lb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 区分多个instance的VRRP组播,同网段不能重复,取值在0-255之间
# 可以直接指定数字,如ROUTER_ID: 69
# 可以直接指定数字,如ROUTER_ID: 111
# 取100~200间的随机数
#ROUTER_ID: "{{ 200 | random(100,1) }}"
ROUTER_ID: 69
#ROUTER_ID: "{{ 200 | random }}"
ROUTER_ID: 111

# haproxy负载均衡算法,常见如下:
# "roundrobin": 基于服务器权重的轮询
# "leastconn": 基于服务器最小连接数
# "source": 基于请求源IP地址
# "uri": 基于请求的URI
BALANCE_ALG: "roundrobin"
2 changes: 1 addition & 1 deletion roles/lb/templates/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ listen kube-master
bind 0.0.0.0:{{ KUBE_APISERVER.split(':')[2] }}
mode tcp
option tcplog
balance source
balance {{ BALANCE_ALG }}
{% for host in groups['kube-master'] %}
server {{ host }} {{ host }}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
Expand Down

0 comments on commit 870d51e

Please sign in to comment.