kubeasz/21.addmaster.yml

58 lines
1.6 KiB
YAML

# reconfigure and restart the haproxy service
- hosts: lb
roles:
- lb
- hosts: new-master
roles:
- { role: chrony, when: "hostvars[groups.deploy[0]]['NTP_ENABLED'] == 'yes'" }
- prepare
- docker
- kube-master
- kube-node
#
- { role: calico, when: "CLUSTER_NETWORK == 'calico'" }
- { role: cilium, when: "CLUSTER_NETWORK == 'cilium'" }
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
#
tasks:
- name: Making master nodes SchedulingDisabled
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
delegate_to: "{{ groups.deploy[0] }}"
when: DEPLOY_MODE != "allinone"
ignore_errors: true
- name: Setting master role name
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