-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube_cluster_install.yml
135 lines (118 loc) · 3.26 KB
/
kube_cluster_install.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
- name: install kubernetes cluster
hosts: kubecluster
become: yes
gather_facts: yes
vars:
docker_cgroup_driver: systemd
docker_log_max_size: 100m
docker_log_driver: json-file
docker_storage_driver: overlay2
hold_k8s_packages: yes
handlers:
- name: restart
reboot:
reboot_timeout: 300
msg: rebooting so that changes take effect. please wait.
- name: restart docker
service:
name: docker
state: restarted
tasks:
- debug:
var: inventory_hostname
tags:
- hostname
- name: set hostname
hostname:
name: "{{ inventory_hostname }}"
notify: restart
tags:
- hostname
- name: enable cgroups
lineinfile:
path: /boot/firmware/cmdline.txt
regexp: '^(.*) rootwait fixrtc'
line: '\1 rootwait fixrtc cgroup_enable=memory swapaccount=1 cgroup_memory=1 cgroup_enable=cpuset'
backrefs: yes
notify: restart
- name: update packages
apt:
name: "*"
state: latest
update_cache: yes
- name: install supporting packages
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- net-tools
- traceroute
state: present
- name: master packages
block:
- name: install pip
apt:
name:
- python3-pip
state: present
- name: ensure supporting python packages are installed
pip:
name:
- openshift
- pyyaml
when: node_type == "master"
- name: add gpg keys
apt_key:
url: "{{ item }}"
loop:
- https://download.docker.com/linux/ubuntu/gpg
- https://packages.cloud.google.com/apt/doc/apt-key.gpg
- name: add docker and k8s repositories
apt_repository:
repo: "{{ item }}"
state: present
loop:
- deb [arch=arm64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
- deb https://apt.kubernetes.io kubernetes-xenial main
- name: install docker and k8s
apt:
name: "{{ item }}"
state: present
loop:
- docker-ce
- docker-ce-cli
- containerd.io
- kubelet
- kubeadm
- kubectl
- name: configure docker daemon
template:
src: daemon.json.j2
dest: /etc/docker/daemon.json
owner: root
group: docker
mode: '0664'
notify: restart docker
- name: allow iptables to see bridged traffic
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
sysctl_file: /etc/sysctl.d/k8s.conf
reload: yes
loop:
- name: net.bridge.bridge-nf-call-ip6tables
value: 1
- name: net.bridge.bridge-nf-call-iptables
value: 1
- name: check to see what packages are marked as held
command: apt-mark showhold
register: apt_mark
changed_when: no
- name: mark k8s packages as held
command: apt-mark hold kubelet kubeadm kubectl
when: (hold_k8s_packages | bool) and (apt_mark.stdout.find('kube') == -1)