-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.yaml
51 lines (45 loc) · 1.31 KB
/
master.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
---
- hosts: masters
become: yes
vars:
pod_network_cidr: "10.244.0.0/16"
flannel_url: "https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml"
tasks:
- name: Remove kubeadm cache files
file:
name: "{{ item }}"
state: absent
loop:
- "cluster_reseted.txt"
- "cluster_initialized.txt"
- name: Reset kubeadm components
shell: "kubeadm reset --force >> cluster_reseted.txt"
args:
chdir: $HOME
creates: cluster_reseted.txt
- name: Initalize the cluster
shell: kubeadm init --pod-network-cidr={{ pod_network_cidr }} >> cluster_initialized.txt
args:
chdir: $HOME
creates: cluster_initialized.txt
- name: Create .kube directory
become: yes
become_user: sysops
file:
path: $HOME/.kube
state: directory
mode: 0755
- name: Copy admin.conf to user's .kube config
copy:
src: /etc/kubernetes/admin.conf
dest: /home/sysops/.kube/config
remote_src: yes
owner: sysops
- name: Install Pod network
become: yes
become_user: sysops
shell: |
kubectl apply -f {{ flannel_url }} >> pod_network_setup.txt
args:
chdir: $HOME
creates: pod_network_setup.txt