-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-k8s-cp-instance-prep.yaml
61 lines (48 loc) · 1.83 KB
/
2-k8s-cp-instance-prep.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
52
53
54
55
56
57
58
59
60
- hosts: ctrlplane_instances
become: yes
tasks:
- name: Delay before start (15 seconds)
pause:
seconds: 15
- name: start kubelet
service:
name: kubelet
enabled: yes
state: started
- name: initialize K8S cluster
shell: kubeadm init --apiserver-cert-extra-sans={{ ansible_ssh_host }} --apiserver-advertise-address={{ ctrl_plane_private_ip }} --pod-network-cidr={{ pod_network_cidr }} --cri-socket unix:///run/containerd/containerd.sock
- name: create /root/.kube directory
file:
path: /root/.kube
state: directory
mode: 0755
- name: create /home/ec2-user/.kube directory
file:
path: /home/ec2-user/.kube
state: directory
mode: 0755
- name: Copy config file to root and ec2-user home directories
ansible.builtin.copy:
remote_src: yes
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: /etc/kubernetes/admin.conf, dest: /root/.kube/config }
- { src: /etc/kubernetes/admin.conf, dest: /home/ec2-user/.kube/config }
- name: Wait 30 seconds
pause:
seconds: 30
- name: Untaint the controlplane
shell: kubectl taint nodes --all node-role.kubernetes.io/control-plane-
- name: Installing Calico
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
- name: Download Calico custom-resources.yaml
get_url:
url: https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml
mode: '644'
dest: ~/custom-resources.yaml
validate_certs: no
- name: Modify Calico custom-resources.yaml
shell: sed -i "s#192.168.0.0/16#{{ pod_network_cidr }}#" ~/custom-resources.yaml
- name: Install Calico custom-resources.yaml manifest
shell: kubectl apply -f ~/custom-resources.yaml