优化增加node/增加master节点流程

pull/465/head
gjmzj 2019-02-15 10:10:43 +08:00
parent 98e6623d10
commit 81bb83b3b7
5 changed files with 63 additions and 1 deletions

View File

@ -38,7 +38,7 @@
lineinfile:
dest: "{{ base_dir }}/hosts"
state: present
insertafter: '^\[etcd\]'
insertafter: '^\[etcd'
firstmatch: yes
line: "{{ inventory_hostname }} NODE_NAME={{ NODE_NAME }}"
connection: local

View File

@ -9,3 +9,31 @@
- { role: cilium, when: "CLUSTER_NETWORK == 'cilium'" }
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
# modify the ansible hosts file
- hosts:
- new-node
tasks:
- name: tag new-node FINISHED=yes
shell: 'sed -i "/\[new-node/,/\[harbor/s/{{ inventory_hostname }}/{{ inventory_hostname }} FINISHED=yes/" {{ base_dir }}/hosts'
args:
warn: false
connection: local
- name: cp new-node to 'kube-node' group
lineinfile:
dest: "{{ base_dir }}/hosts"
state: present
insertafter: '^\[kube-node'
firstmatch: yes
line: "{{ inventory_hostname }} NEW_NODE=yes"
connection: local
- hosts: deploy
tasks:
- name: rm new-node in ansible hosts
lineinfile:
dest: "{{ base_dir }}/hosts"
state: absent
regexp: 'FINISHED=yes'
connection: local

View File

@ -27,3 +27,31 @@
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"
# modify the ansible hosts file
- hosts:
- new-master
tasks:
- name: tag new-master FINISHED=yes
shell: 'sed -i "/\[new-master/,/\[kube-node/s/{{ inventory_hostname }}/{{ inventory_hostname }} FINISHED=yes/" {{ base_dir }}/hosts'
args:
warn: false
connection: local
- name: cp new-master to 'kube-master' group
lineinfile:
dest: "{{ base_dir }}/hosts"
state: present
insertafter: '^\[kube-master'
firstmatch: yes
line: "{{ inventory_hostname }} NEW_MASTER=yes"
connection: local
- hosts: deploy
tasks:
- name: rm new-master in ansible hosts
lineinfile:
dest: "{{ base_dir }}/hosts"
state: absent
regexp: 'FINISHED=yes'
connection: local

View File

@ -10,6 +10,7 @@
- 新节点安装 kube-node 服务
- 新节点安装网络插件相关
- 禁止业务 pod调度到新master节点
- 修改hosts文件把 new-master 组成员转移到 kube-master 组
### 操作步骤
@ -54,3 +55,5 @@ NAME STATUS ROLES AGE VERSION
### 后续
上述步骤验证成功确认新节点工作正常后为了方便后续再次添加节点在ansible hosts文件中把 [new-master] 组下的节点全部复制到 [kube-master] 组下,并清空 [new-master] 组中的节点。
- 注:新版本 kubeasz 已经自动完成 new-master 组成员转移到 kube-master 组

View File

@ -5,6 +5,7 @@
- 新节点安装 docker 服务
- 新节点安装 kube-node 服务
- 新节点安装网络插件相关
- 修改hosts文件把 new-node 组成员转移到 kube-node 组
### 操作步骤
@ -40,3 +41,5 @@ $ kubectl get pod -n kube-system
### 后续
上述步骤验证成功确认新节点工作正常后为了方便后续再次添加节点在ansible hosts文件中把 [new-node] 组下的节点全部复制到 [kube-node] 组下,并清空 [new-node] 组的节点。
- 注:新版本 kubeasz 已经自动完成 new-node 组成员转移到 kube-node 组