-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_kubernetes_cluster.yml
More file actions
58 lines (52 loc) · 1.94 KB
/
setup_kubernetes_cluster.yml
File metadata and controls
58 lines (52 loc) · 1.94 KB
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
- hosts: kubernetes-master
become: yes
tasks:
- name: Initialize the cluster
shell: kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=61.252.52.18 >> cluster_initialized.txt
args:
chdir: $HOME
creates: cluster_initialized.txt
- name: Create .kube directory
become: yes
become_user: tein
file:
path: $HOME/.kube
state: directory
mode: 0755
- name: Copy admin.conf to user's kube config
become: yes
copy:
src: /etc/kubernetes/admin.conf
dest: /home/{{ ansible_user }}/.kube/config
remote_src: yes
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
# - name: Download Calico yaml file
#become_user: usman
#get_url:
#url: kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml
#dest: /home/usman/calico.yaml
#- name: Update calico.yaml file to insert IP_AUTODETECTION_METHOD=can-reach=IPAddress
#blockinfile:
#path: /home/usman/calico.yaml
#backup: no
#marker: "# {mark} Inserting IP_AUTODETECTION_METHOD"
#block: |2
# # Auto-detection IP method
# - name: IP_AUTODETECTION_METHOD
# value: "can-reach=10.0.2.15"
#insertbefore: "Enable IPIP"
- name: Install tigera operator
become: yes
become_user: tein
shell: kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml >> tigera_operator.txt
args:
chdir: $HOME
creates: tigera_operator.txt
- name: Apply the calico manisfest file using kubectl apply -f calico.yaml
become: yes
become_user: tein
shell: kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml >> calico_network.txt
args:
chdir: $HOME
creates: calico_network.txt