forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15_apply_network_plugin.yml
More file actions
90 lines (75 loc) · 3.3 KB
/
15_apply_network_plugin.yml
File metadata and controls
90 lines (75 loc) · 3.3 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
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
---
- name: Apply network plugin
hosts: masters
run_once: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- block:
- name: Apply network addon - Calico
command: kubectl apply -f {{ cni_plugins.calico.calico_operator }}
- name: Apply CRDs
command: kubectl apply -f {{ cni_plugins.calico.calico_crd }}
- name: Patch operator resource with correct CIDR
command: "kubectl patch installation default --type='json' -p='[{\"op\": \"replace\", \"path\": \"/spec/calicoNetwork/ipPools/0/cidr\", \"value\": {{ k8s.network.pod_cidr }} }]'"
- name: Wait for Calico pods to be created
shell: "kubectl get po --namespace=calico-system --output=jsonpath='{.items[*].metadata.name}'"
register: calico_dns_pods_created
until: item in calico_dns_pods_created.stdout
retries: 10
delay: 30
with_items:
- calico-node
- calico-typha
- calico-kube-controllers
- name: Wait for Calico pods become ready
shell: "kubectl wait --namespace=calico-system --for=condition=Ready pods --selector k8s-app=calico-node --timeout=600s"
register: calico_dns_pods_ready
when: k8s.network.cni_plugin == 'calico'
- block:
- name: Download Cilium CLI
unarchive:
src: "{{ cni_plugins.cilium.cilium_cli }}"
dest: /usr/local/bin
remote_src: yes
become: true
- name: Run Cilium installer
command: cilium install --ipam kubernetes
- name: Ensure Cilium is correctly installed
command: cilium status --wait
when: k8s.network.cni_plugin == 'cilium'
- block:
- name: Download flannel manifest
get_url:
url: "{{ cni_plugins.flannel.flannel_repo }}"
dest: /tmp/kube-flannel.yml
- name: Patch kube-flannel to use host-gw instead of vxlan
replace:
path: /tmp/kube-flannel.yml
regexp: 'vxlan'
replace: 'host-gw'
- name: apply network addon - Flannel
shell: kubectl apply -f /tmp/kube-flannel.yml
- name: Wait for flannel pods to be created
shell: "kubectl get po --namespace=kube-system --selector app=flannel --output=jsonpath='{.items[*].metadata.name}'"
register: flannel_dns_pods_created
until: item in flannel_dns_pods_created.stdout
retries: 10
delay: 30
with_items:
- kube-flannel-ds
- name: Wait for flannel pods to become ready
shell: "kubectl wait --namespace=kube-system --for=condition=Ready pods --selector app=flannel --timeout=600s"
register: flannel_dns_pods_ready
when: k8s.network.cni_plugin == 'flannel'
- name: Wait for coredns pods become created
shell: "kubectl get po --namespace=kube-system --selector k8s-app=kube-dns --output=jsonpath='{.items[*].metadata.name}'"
register: kube_dns_pods_created
until: item in kube_dns_pods_created.stdout
retries: 10
delay: 30
with_items:
- coredns
- name: Wait for core-dns pods become ready
shell: "kubectl wait --namespace=kube-system --for=condition=Ready pods --selector k8s-app=kube-dns --timeout=600s"
register: kube_dns_pods_ready