-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaster-init.yml
57 lines (56 loc) · 2.43 KB
/
master-init.yml
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: master
tasks:
- name: initialise master
shell: kubeadm init --apiserver-advertise-address={{ ansible_eth0.ipv4.address }} --pod-network-cidr=192.168.0.0/16
when: cni == "calico"
- name: initialise master
shell: kubeadm init --apiserver-advertise-address={{ ansible_eth0.ipv4.address }} --skip-phases=addon/kube-proxy
when: cni == "cilium"
- name: initialise master
shell: kubeadm init --apiserver-advertise-address={{ ansible_eth0.ipv4.address }}
when: cni == "skip"
- name: Create /root/.kube
file:
path: /root/.kube
state: directory
owner: root
- name: "Create /home/{{ user }}/.kube"
file:
path: "/home/{{ user }}/.kube"
state: directory
owner: "{{ user }}"
- name: Copy admin.conf to root
shell: cp /etc/kubernetes/admin.conf /root/.kube/config
- name: Copy admin.conf to "{{ user }}"
shell: cp /etc/kubernetes/admin.conf /home/{{ user }}/.kube/config
- name: bash_completition
shell: kubectl completion bash >/etc/bash_completion.d/kubectl
- name: make shure /home/{{ user }}/.kube/config belongs to 22m
file:
path: /home/{{ user }}/.kube/config
owner: "{{ user }}"
- name: initialise calico
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/tigera-operator.yaml
when: cni == "calico"
- name: initialise calico
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/custom-resources.yaml
when: cni == "calico"
#- name: initialise calicoctl
# shell: curl -O -L https://github.com/projectcalico/calicoctl/releases/download/v3.18.1/calicoctl
# when: cni == "calico"
- name: initialise cilium
shell: kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/v1.9/install/kubernetes/quick-install.yaml
when: cni == "cilium"
- debug:
msg: He das mit Cilium klappt so nicht. Wir brauchen ja die externe Addresse/Port vom API-Server
when: cni == "cilium"
- name: Install Metrics-Server
shell: kubectl apply -f https://raw.githubusercontent.com/erkules/k8sworkshop/master/System/metrics-server.yaml
- name: Add IP address of all hosts to all hosts
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }}$'
line: "{{ hostvars[item].ansible_host }} {{item}}"
state: present
when: hostvars[item].ansible_host is defined
with_items: "{{ groups.all }}"