2018-09-29 09:06:19 +08:00
|
|
|
# cluster-restore playbook
|
|
|
|
# read the guide: 'op/cluster_restore.md'
|
2018-07-23 16:59:44 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to restore CA sth on 'deploy' node
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts: deploy
|
|
|
|
tasks:
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Restoring dirs of CA sth
|
2018-07-23 16:59:44 +08:00
|
|
|
file: name=/etc/kubernetes/ssl/ state=directory
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Restoring CA sth
|
2018-07-23 16:59:44 +08:00
|
|
|
copy:
|
|
|
|
src: "{{ base_dir }}/roles/cluster-backup/files/ca/{{ item }}"
|
|
|
|
dest: "{{ ca_dir }}/{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- ca.pem
|
|
|
|
- ca-key.pem
|
|
|
|
- ca.csr
|
|
|
|
- ca-csr.json
|
|
|
|
- ca-config.json
|
|
|
|
|
|
|
|
- hosts: deploy
|
|
|
|
roles:
|
|
|
|
- deploy
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# pre-tasks on all nodes
|
2019-06-23 07:36:51 +08:00
|
|
|
- hosts:
|
|
|
|
- kube-master
|
|
|
|
- kube-node
|
|
|
|
- etcd
|
2018-07-23 16:59:44 +08:00
|
|
|
roles:
|
|
|
|
- prepare
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# [optional] only needed by multi-master cluster
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts: lb
|
|
|
|
roles:
|
|
|
|
- lb
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to install etcd cluster
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts: etcd
|
|
|
|
roles:
|
|
|
|
- etcd
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to install docker
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts:
|
|
|
|
- kube-master
|
|
|
|
- kube-node
|
|
|
|
roles:
|
|
|
|
- docker
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to set up 'kube-master' nodes
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts:
|
|
|
|
- kube-master
|
|
|
|
roles:
|
|
|
|
- kube-master
|
|
|
|
- kube-node
|
2018-09-29 09:06:19 +08:00
|
|
|
#
|
2018-07-23 16:59:44 +08:00
|
|
|
tasks:
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Making master nodes SchedulingDisabled
|
2018-07-23 16:59:44 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
|
|
|
|
when: DEPLOY_MODE != "allinone"
|
|
|
|
ignore_errors: true
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Setting master role name
|
2018-07-23 16:59:44 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
|
|
|
|
ignore_errors: true
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to set up 'kube-node' nodes
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts:
|
|
|
|
- kube-node
|
|
|
|
roles:
|
|
|
|
- kube-node
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to restore data of etcd cluster
|
2018-07-23 16:59:44 +08:00
|
|
|
- hosts: etcd
|
|
|
|
roles:
|
|
|
|
- cluster-restore
|
|
|
|
|