-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoin-cluster-tasks.yaml
63 lines (52 loc) · 1.61 KB
/
join-cluster-tasks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
- name: hold packages
shell: apt-mark hold kubelet kubeadm kubectl
- name: kubeadm reset
shell: kubeadm reset --force && kubeadm reset phase cleanup-node
- name: create .kube directory
become_user: ubuntu
file:
path: $HOME/.kube
state: directory
mode: 0755
register: kube_path
when: "'control' in group_names"
- name: get kubeadm certificate key
shell: kubeadm certs certificate-key
register: CERT_KEY
delegate_to: "{{ groups.control[0] }}"
when: "'control' in group_names"
- name: upload certificate
shell: kubeadm init phase upload-certs --upload-certs --certificate-key={{ CERT_KEY.stdout }}
delegate_to: "{{ groups.control[0] }}"
when: "'control' in group_names"
- name: get join command for control plane nodes
become: false
shell: kubeadm token create --print-join-command --certificate-key={{ CERT_KEY.stdout }}
register: JOIN_COMMAND
delegate_to: "{{ groups.control[0] }}"
when: "'control' in group_names"
- name: set facts join command
set_fact:
join_command: "{{ JOIN_COMMAND.stdout }}"
when: "'control' in group_names"
- name: get join command for worker nodes
shell: kubeadm token create --print-join-command
register: JOIN_COMMAND
delegate_to: "{{ groups.control[0] }}"
when: "'worker' in group_names"
- name: set facts join command
set_fact:
join_command: "{{ JOIN_COMMAND.stdout }}"
when: "'worker' in group_names"
- name: show join command
debug:
msg:
- "{{ join_command }}"
- name: join cluster
shell: "{{ join_command }}"
register: join_cmd_output
- name: show join cluster
debug:
msg:
- "{{ join_cmd_output.stdout }}"