Skip to content

Commit

Permalink
简化新增节点步骤
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Jun 10, 2018
1 parent 9f17296 commit af872c8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 33 deletions.
25 changes: 3 additions & 22 deletions docs/op/AddMaster.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,21 @@

### 操作步骤

按照本项目说明,首先确保deploy节点能够ssh免密码登陆新增节点,然后在**deploy**节点执行三步
按照本项目说明,首先确保deploy节点能够ssh免密码登陆新增节点,然后在**deploy**节点执行两步

- 修改ansible hosts 文件,在 [new-master] 组添加新增的节点;在[lb] 组添加新增master 节点,举例如下:
- 修改ansible hosts 文件,在 [new-master] 组添加新增的节点,举例如下:

``` bash
[lb]
192.168.1.1 LB_IF="ens3" LB_ROLE=backup
192.168.1.2 LB_IF="ens3" LB_ROLE=master
[lb:vars]
master1="192.168.1.1:6443"
master2="192.168.1.2:6443"
master3="192.168.1.5:6443" # 新增 master节点
...
[new-master]
192.168.1.5 # 新增 master节点

```
- 修改roles/lb/templates/haproxy.cfg.j2 文件,增加新增的master节点,举例如下:

``` bash
listen kube-master
bind 0.0.0.0:{{ KUBE_APISERVER.split(':')[2] }}
mode tcp
option tcplog
balance source
server s1 {{ master1 }} check inter 10000 fall 2 rise 2 weight 1
server s2 {{ master2 }} check inter 10000 fall 2 rise 2 weight 1
server s3 {{ master3 }} check inter 10000 fall 2 rise 2 weight 1 # 新增 master节点
```

- 执行安装脚本

``` bash
$ cd /etc/ansible && ansible-playbook 21.addmaster.yml
$ ansible-playbook /etc/ansible/21.addmaster.yml
```

### 验证
Expand Down
4 changes: 2 additions & 2 deletions docs/op/AddNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
...
# 预留组,后续添加node节点使用
[new-node]
192.168.1.6 NODE_ID=node6
192.168.1.6 #新增node节点
...
```
- 执行安装脚本

``` bash
$ cd /etc/ansible && ansible-playbook 20.addnode.yml
$ ansible-playbook /etc/ansible/20.addnode.yml
```

### 验证
Expand Down
7 changes: 4 additions & 3 deletions roles/lb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 区分多个instance的VRRP组播,同网段不能重复,取值在0-255之间
# 可以直接指定数字,如ROUTER_ID=59
# 本项目取100~200间的随机数
ROUTER_ID: "{{ 200 | random(100,1) }}"
# 可以直接指定数字,如ROUTER_ID: 69
# 取100~200间的随机数
#ROUTER_ID: "{{ 200 | random(100,1) }}"
ROUTER_ID: 69
12 changes: 6 additions & 6 deletions roles/lb/templates/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ listen kube-master
mode tcp
option tcplog
balance source
{% for host in groups['kube-master'] %}
server {{host.inventory_hostname}} {{host.inventory_hostname}}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-master'] %}
server {{host.inventory_hostname}} {{host.inventory_hostname}}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['kube-master'] %}
server {{ host }} {{ host }}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-master'] %}
server {{ host }} {{ host }}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}

0 comments on commit af872c8

Please sign in to comment.