-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_k8s.yaml
96 lines (85 loc) · 2.28 KB
/
install_k8s.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
---
- hosts: all
remote_user: kube
become: true
become_method: sudo
become_user: root
gather_facts: true
connection: ssh
vars:
sysctl_config:
net.bridge.bridge-nf-call-iptables: 1
net.ipv4.ip_forward: 1
net.bridge.bridge-nf-call-ip6tables: 1
tasks:
- name: load moduls
community.general.modprobe:
name: "{{ item }}"
state: present
with_items:
- overlay
- br_netfilter
- name: add conf for containerd
ansible.posix.sysctl:
sysctl_file: "/etc/sysctl.d/99-kubernetes-cri.conf"
name: '{{ item.key }}'
value: '{{ item.value }}'
sysctl_set: true
state: present
reload: true
ignoreerrors: true
with_dict: '{{ sysctl_config }}'
- name: install containerd
ansible.builtin.apt:
name:
- containerd
- apt-transport-https
- curl
update_cache: true
- name: create folder
ansible.builtin.file:
path: /etc/containerd
state: directory
recurse: true
- name: init conf containerd
ansible.builtin.shell: |
containerd config default | tee /etc/containerd/config.toml
args:
creates: "/etc/containerd/config.toml"
notify:
- restart containerd
- name: disable swap
ansible.posix.mount:
name: swap
fstype: swap
state: absent
- name: add an apt signing key
ansible.builtin.apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present
- name: add K8s Source
ansible.builtin.blockinfile:
path: "/etc/apt/sources.list.d/kubernetes.list"
block: |
deb https://apt.kubernetes.io/ kubernetes-xenial main
create: true
- name: install kubernetes
ansible.builtin.apt:
name:
- kubelet=1.20.1-00
- kubeadm=1.20.1-00
- kubectl=1.20.1-00
update_cache: true
- name: prevent kube from being upgraded
ansible.builtin.dpkg_selections:
name: "{{ item }}"
selection: hold
with_items:
- kubelet
- kubeadm
- kubectl
handlers:
- name: restart containerd
ansible.builtin.service:
name: containerd
state: restarted