-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkube-api.yml
58 lines (57 loc) · 2 KB
/
kube-api.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
58
- hosts: "{{ target_hosts | default('kube') }}"
gather_facts: yes
become: true
tasks:
- name: start kubelet
systemd:
name: kubelet
enabled: yes
state: started
when: inventory_hostname == groups['kube'][0]
- name: pull images
shell: kubeadm config images pull
when: inventory_hostname == groups['kube'][0]
- name: perform kubeadm init
shell: kubeadm init --pod-network-cidr=192.168.0.0/16 --control-plane-endpoint=kube-api
register: kube_init
when: inventory_hostname == groups['kube'][0]
- debug: var=kube_init
- name: set up user
shell: "{{ item }}"
loop:
- mkdir -p $HOME/.kube
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
when: inventory_hostname == groups['kube'][0]
- name: generate join
shell: kubeadm token create --print-join-command
register: join_cmd
when: inventory_hostname == groups['kube'][0]
- debug: var=join_cmd.stdout
- name: create shell file locally
shell: echo "{{ join_cmd.stdout }}" > /tmp/go.sh
delegate_to: localhost
when: inventory_hostname == groups['kube'][0]
- name: copy file to workers
copy:
src: /tmp/go.sh
dest: /tmp/join.sh
mode: 700
when: (inventory_hostname == groups['kube'][1]) or (inventory_hostname == groups['kube'][2])
- name: install network plugin on master
shell: kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
when: inventory_hostname == groups['kube'][0]
- name: run join command on worker nodes
shell: /tmp/join.sh
when: (inventory_hostname == groups['kube'][1]) or (inventory_hostname == groups['kube'][2])
- name: copy demo files to api server
copy:
src: "f5-kube-files/{{ item }}"
dest: "{{ item }}"
loop:
- create-f5-user-role.sh
- deployment-hello.yml
- f5-cis-nodeport-deploy.yml
- ingress-hello.yml
- service-hello.yml
when: inventory_hostname == groups['kube'][0]