forked from chris-short/rak8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.yml
84 lines (68 loc) · 1.73 KB
/
cluster.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
- hosts: all
pre_tasks:
- name: Check for kubeadm
stat:
path: /usr/bin/kubeadm
register: kubeadm_exists
become: true
- name: Reset Flannel
command: ip link delete flannel.1
ignore_errors: true
tags: [ never, provision ]
- name: Reset Kubernetes
shell: kubeadm reset -f
ignore_errors: true
tags: [ never, provision ]
roles:
- common
- kubeadm
post_tasks:
- name: Remove dependencies that are no longer required
apt:
autoremove: yes
- name: Remove useless packages from the cache
apt:
autoclean: yes
- hosts: master
roles:
- master
# - dashboard
post_tasks:
- name: Get join command
command: kubeadm token create --print-join-command
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
register: kubeadm_join_command_generate
tags: [ never, provision ]
- name: Show join command
debug:
msg='{{ kubeadm_join_command_generate.stdout }}'
tags: [ never, provision ]
- name: Get Kube config
fetch:
src: /etc/kubernetes/admin.conf
dest: ./kube.config
tags: [ never, provision ]
- hosts: all:!master
gather_facts: no
become: true
become_method: sudo
roles:
- workers
tasks:
- name: Start k8s services
service:
name: "{{item}}"
state: restarted
enabled: yes
with_items:
- kubelet
- docker
- containerd
tags: [ provision ]
- name: Join cluster
command: "{{ hostvars[groups['master'][0]].kubeadm_join_command_generate.stdout }}"
tags: [ never, provision ]
- name: Reload systemd files on Nodes
systemd:
daemon_reload: yes