-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster.yml.weave
114 lines (82 loc) · 2.38 KB
/
cluster.yml.weave
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
- hosts: localhost
gather_facts: false
roles:
- role: admission_token
tags:
- token
tasks:
- debug:
var: admission_token
tags:
- token
- hosts: "{{ hostvars.localhost.groups.master | join(',') }}"
become: true
roles:
- role: kubeadm_install
tags:
- repo
- master
- nodes
tasks:
# Implements Step 2 of http://kubernetes.io/docs/getting-started-guides/kubeadm/
- name: Initialize master
command: kubeadm init --token {{ hostvars.localhost.admission_token }}
args:
creates: /etc/kubernetes/pki
register: master_init
ignore_errors: true
tags:
- master
- init
- debug:
var: master_init.stdout_lines
# Not 100% sure that the creates clause is correct
- hosts: "{{ hostvars.localhost.groups.nodes | join(',') }}"
become: true
roles:
- role: kubeadm_install
tags:
- repo
- master
- nodes
tasks:
# Implements Step 3 of http://kubernetes.io/docs/getting-started-guides/kubeadm/
- set_fact:
master_ip_address: '{{ master_ip_address_configured }}'
when: master_ip_address_configured is defined
- set_fact:
master_ip_address: "{{ hostvars[groups['master'][0]]['ansible_default_ipv4']['address'] }}"
when: master_ip_address_configured is not defined
- name: Join nodes to cluster
command: kubeadm join --token {{ hostvars.localhost.admission_token }} {{ master_ip_address }}
args:
creates: /etc/kubernetes/kubelet.conf
register: node_join
ignore_errors: true
tags:
- nodes
- join
- debug:
var: node_join.stdout_lines
# Not 100% sure that the creates clause is correct
- hosts: "{{ hostvars.localhost.groups.master | join(',') }}"
become: true
tasks:
# Implements Step 4 of http://kubernetes.io/docs/getting-started-guides/kubeadm/
- name: Install pod network
command: kubectl apply -f https://git.io/weave-kube
register: pod_network
tags:
- master
- network
- debug:
var: pod_network.stdout_lines
- name: Copy
fetch:
src: /etc/kubernetes/admin.conf
dest: remotes/{{ hostvars[groups['master'][0]]['cluster_name'] }}.conf
flat: true
tags:
- master
- remote