-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubeadm-install.yaml
106 lines (93 loc) · 2.89 KB
/
kubeadm-install.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
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
---
- name: Kubeadm and Containerd Setup
hosts: all
remote_user: root
tasks:
- name: Add Kernel Modules to Load
ansible.builtin.lineinfile:
path: /etc/modules-load.d/k8s-bootstrap.conf
state: present
create: yes
line: "{{ item }}"
loop:
- br_netfilter
- overlay
- name: Add sysctl params
ansible.builtin.lineinfile:
path: /etc/sysctl.d/k8s-bootstrap.conf
state: present
create: yes
line: "{{ item }}"
loop:
- net.bridge.bridge-nf-call-iptables = 1
- net.ipv4.ip_forward = 1
- net.bridge.bridge-nf-call-ip6tables = 1
- name: Add Kubernetes and Docker GPG apt keys
ansible.builtin.apt_key:
url: "{{ item }}"
state: present
loop:
- https://packages.cloud.google.com/apt/doc/apt-key.gpg
- https://download.docker.com/linux/debian/gpg
- name: Add Kubeadm Repository
ansible.builtin.apt_repository:
repo: "{{ item }}"
state: present
loop:
- deb https://apt.kubernetes.io/ kubernetes-xenial main
- deb https://download.docker.com/linux/debian buster stable
- name: Update all packages for Debian-like Systems
ansible.builtin.apt:
update_cache: yes
name: '*'
force_apt_get: yes
state: latest
when: ansible_facts['os_family'] == 'Debian'
notify: Autoremove Packages using APT
- name: Install necessary packages
ansible.builtin.package:
name:
- curl
- ifupdown
- ca-certificates
- apt-transport-https
- gnupg
- lsb-release
- kubelet
- kubeadm
- kubectl
- containerd.io
state: latest
- name: Generate Default Containerd Config
raw: containerd config default | sudo tee /etc/containerd/config.toml
- name: Add Systemd as the cgroup driver for containerd
ansible.builtin.lineinfile:
state: present
path: /etc/containerd/config.toml
insertafter: ' \[plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options\]'
line: ' SystemdCgroup = true'
## DigitalOcean specific cleanup tasks
- name: Remove Cloud-Init
ansible.builtin.package:
name: cloud-init
state: absent
when: ansible_facts['os_family'] == 'Debian'
notify: Autoremove Packages using APT
- name: Remove Cloud-init directories
ansible.builtin.file:
name: "{{ item }}"
state: absent
loop:
- /var/lib/cloud
- /etc/cloud
- /usr/lib/python3/dist-packages/cloudinit/sources/helpers
- name: Editing /etc/network/interfaces to remove Private IPs
raw: sed -i '/post-up ifup eth0:1/,$d' /etc/network/interfaces
## Digital Ocean specific cleanup ends here
- name: Unconditionally reboot the machine with all defaults
ansible.builtin.reboot:
handlers:
- name: Autoremove Packages using APT
ansible.builtin.apt:
autoremove: yes
purge: yes