-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker_config.yml
More file actions
142 lines (120 loc) · 3.6 KB
/
Copy pathworker_config.yml
File metadata and controls
142 lines (120 loc) · 3.6 KB
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
136
137
138
139
140
141
142
---
- name: Kubernetes worker node setup
hosts: worker
vars:
gather_facts: false
# playbook designed with data from https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
# designed for use on ubuntu server
tasks:
- name: Download CNI for amd64
ansible.builtin.get_url:
dest: /home/{{ ansible_user }}/cni-plugins-linux-amd64-v1.1.1.tgz
url: https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz
mode: '0755'
checksum: sha256:b275772da4026d2161bf8a8b41ed4786754c8a93ebfb6564006d5da7f23831e5
- name: Create /opt/cni/bin
become: true
ansible.builtin.file:
path: /opt/cni/bin
state: directory
mode: '0755'
- name: Unarchive CNI
become: true
ansible.builtin.unarchive:
src: /home/{{ ansible_user }}/cni-plugins-linux-amd64-v1.1.1.tgz
dest: /opt/cni/bin
remote_src: true
creates: /opt/cni/bin/bandwidth
- name: Disable SWAP since kubernetes can't work with swap enabled (1/2)
become: true
ansible.builtin.shell: |
swapoff -a
register: my_output
changed_when: my_output.rc != 0 # Uses the return code to define when the task has changed.
- name: Disable SWAP in fstab since kubernetes can't work with swap enabled (2/2)
become: true
ansible.builtin.replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
replace: '# \1'
- name: Update the apt cache
become: true
ansible.builtin.apt:
update_cache: true
- name: Remove uncomplicated firewall
become: true
ansible.builtin.apt:
name: ufw
state: absent
- name: Install ca-certificates
become: true
ansible.builtin.apt:
name: ca-certificates
state: present
- name: Install firewalld
become: true
ansible.builtin.apt:
name: firewalld
state: present
- name: Create directory for keyrings
become: true
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
- name: Download the Google Cloud public signing key
become: true
ansible.builtin.get_url:
dest: /etc/apt/keyrings/kubernetes-archive-keyring.gpg
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
mode: '0755'
- name: Create kubernetes.list file
become: true
ansible.builtin.file:
path: /etc/apt/sources.list.d/kubernetes.list
state: touch
mode: '0755'
access_time: preserve
- name: Add kubernetes apt repository to kubernetes.list file
become: true
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/kubernetes.list
line: deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main
insertbefore: BOF
- name: Open kubelet API port
become: true
ansible.posix.firewalld:
port: 10250/tcp
permanent: true
state: enabled
- name: Open NodePort services
become: true
ansible.posix.firewalld:
port: 30000-32767/tcp
permanent: true
state: enabled
- name: Update the apt cache 2
become: true
ansible.builtin.apt:
update_cache: true
- name: Install containerd
become: true
ansible.builtin.apt:
name: containerd
state: present
- name: Install kubeadm
become: true
ansible.builtin.apt:
name: kubeadm
state: present
- name: Install kubelet
become: true
ansible.builtin.apt:
name: kubelet
state: present
- name: Install kubectl
become: true
ansible.builtin.apt:
name: kubectl
state: present
...