-
Notifications
You must be signed in to change notification settings - Fork 0
/
step-2-cluster-init.yaml
32 lines (29 loc) · 1.21 KB
/
step-2-cluster-init.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
- hosts: master
become: yes
tasks:
- name: Initialize the kubernetes cluster (creating /etc/kubernetes/admin.conf). kube-flannel REQUIRES cidr 10.244.0.0/16.
shell: kubeadm init --pod-network-cidr=10.244.0.0/16 > kubeadm-init-output.txt 2>&1 || { cat kubeadm-init-output.txt; rm -f kubeadm-init-output.txt; false; }
args:
chdir: $HOME
creates: kubeadm-init-output.txt
- name: Create $HOME/.kube directory
become: yes
become_user: centos
file:
path: $HOME/.kube
state: directory
mode: 0755
- name: Copy /etc/kubernetes/admin.conf to user directory, for using kubectl
copy:
src: /etc/kubernetes/admin.conf
dest: /home/centos/.kube/config
remote_src: yes
owner: centos
group: centos
- name: Install kube-flannel pod network
become: yes
become_user: centos
shell: kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml > kubectl-apply-flannel-output.txt 2>&1 || { cat kubectl-apply-flannel-output.txt; rm -f kubectl-apply-flannel-output.txt; false; }
args:
chdir: /home/centos
creates: kubectl-apply-flannel-output.txt