X Tutup
Skip to content

Commit bafc7be

Browse files
committed
kubernetes + containerd installer
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
1 parent 9558ff2 commit bafc7be

File tree

8 files changed

+191
-3
lines changed

8 files changed

+191
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
- hosts: all
3+
become: true
4+
tasks:
5+
- include_vars: vars/vars.yaml # Contains tasks variables for installer
6+
- include: tasks/bootstrap_ubuntu.yaml # Contains tasks bootstrap components for ubuntu systems
7+
when: ansible_distribution == "Ubuntu"
8+
- include: tasks/bootstrap_centos.yaml # Contains tasks bootstrap components for centos systems
9+
when: ansible_distribution == "CentOS"
10+
- include: tasks/k8s.yaml # Contains tasks kubernetes component installation
11+
- include: tasks/binaries.yaml # Contains tasks for pulling containerd and cri-containerd components
12+
13+
- name: "Start Containerd"
14+
systemd: name=containerd daemon_reload=yes state=started enabled=yes
15+
16+
- name: "Start CRI-Containerd"
17+
systemd: name=cri-containerd daemon_reload=yes state=started enabled=yes
18+
19+
- name: "Set bridge-nf-call-iptables"
20+
lineinfile:
21+
line: "net/bridge/bridge-nf-call-iptables = 1"
22+
dest: /etc/sysctl.conf
23+
insertafter: 'EOF'
24+
regexp: '\/net\/bridge\/bridge-nf-call-iptables = 1'
25+
state: present
26+
ignore_errors: true
27+
28+
- name: "Check kubelet args in kubelet config"
29+
shell: grep "^Environment=\"KUBELET_EXTRA_ARGS=" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
30+
ignore_errors: true
31+
register: check_args
32+
33+
- name: "Add runtime args in kubelet conf"
34+
lineinfile:
35+
dest: "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"
36+
line: "Environment=\"KUBELET_EXTRA_ARGS= --container-runtime=remote --runtime-request-timeout=15m --image-service-endpoint=/var/run/cri-containerd.sock --container-runtime-endpoint=/var/run/cri-containerd.sock\""
37+
insertafter: '\[Service\]'
38+
when: check_args.stdout == ""
39+
40+
- name: "Start Kubelet"
41+
systemd: name=kubelet daemon_reload=yes state=started enabled=yes
42+
43+
# TODO This needs to be removed once we have consistent concurrent pull results
44+
- name: "Pre-pull pause container image"
45+
shell: |
46+
/usr/local/bin/ctr pull gcr.io/google_containers/pause:3.0
47+
/usr/local/bin/crictl --runtime-endpoint /var/run/cri-containerd.sock \
48+
pull gcr.io/google_containers/pause:3.0
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
- name: "Create a directory to download binaries"
3+
file: path={{ cri_release_directory }} state=directory
4+
5+
- name: "Get Containerd and CRI-Containerd"
6+
get_url:
7+
validate_certs: "no"
8+
url: "https://storage.googleapis.com/cri-containerd-staging/cri-containerd-{{ cri_containerd_release_version }}.tar.gz"
9+
dest: "{{ cri_release_directory }}"
10+
mode: 0755
11+
12+
- name: "Unpack Containerd and CRI-Containerd"
13+
unarchive:
14+
src: "{{ cri_release_directory }}cri-containerd-{{ cri_containerd_release_version }}.tar.gz"
15+
dest: "{{ cri_release_directory }}"
16+
remote_src: yes
17+
18+
- name: "Install the containerd and cri-containerd binaries"
19+
copy:
20+
src: "{{ cri_release_directory }}usr/local/bin/{{ item }}"
21+
dest: "{{ local_bin_dir }}{{ item }}"
22+
mode: 0755
23+
remote_src: yes
24+
with_items:
25+
- containerd
26+
- containerd-stress
27+
- containerd-shim
28+
- cri-containerd
29+
- ctr
30+
- crictl
31+
32+
- name: "Install runc"
33+
copy:
34+
src: "{{ cri_release_directory }}usr/local/sbin/{{ item }}"
35+
dest: "{{ local_sbin_dir }}{{ item }}"
36+
mode: 0755
37+
remote_src: yes
38+
with_items:
39+
- runc
40+
41+
- name: "Copy containerd systemd service unit"
42+
template: src=../../systemd-units/containerd.service dest=/etc/systemd/system/containerd.service
43+
44+
- name: "Copy cri-containerd systemd service unit"
45+
template: src=../../systemd-units/cri-containerd.service dest=/etc/systemd/system/cri-containerd.service
46+
47+
- name: "Create a directory for cni binary"
48+
file: path={{ cni_bin_dir }} state=directory
49+
50+
- name: "Create a directory for cni config files"
51+
file: path={{ cni_conf_dir }} state=directory
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: "Install required packages on CentOS "
3+
yum:
4+
name: "{{ item }}"
5+
state: latest
6+
with_items:
7+
- unzip
8+
- tar
9+
- btrfs-progs-devel
10+
- libseccomp-devel
11+
- util-linux
12+
- socat
13+
- libselinux-python
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: "Install required packages on Ubuntu"
3+
package:
4+
name: "{{ item }}"
5+
state: latest
6+
with_items:
7+
- unzip
8+
- tar
9+
- apt-transport-https
10+
- btrfs-tools
11+
- libapparmor-dev
12+
- libseccomp-dev # Revisit the need and alternatives for all -dev packages
13+
- libseccomp2
14+
- socat
15+
- util-linux
16+
# TODO: Limited support for trusty for nsenter. Need to handle/verify

contrib/ansible/tasks/k8s.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
- name: "Add gpg key (Ubuntu)"
3+
apt_key:
4+
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
5+
state: present
6+
when: ansible_distribution == "Ubuntu"
7+
8+
- name: "Add kubernetes source list (Ubuntu)"
9+
apt_repository:
10+
repo: "deb http://apt.kubernetes.io/ kubernetes-{{ ansible_distribution_release }} main"
11+
state: present
12+
filename: "kubernetes"
13+
when: ansible_distribution == "Ubuntu"
14+
15+
- name: "Update the repository cache (Ubuntu)"
16+
apt:
17+
update_cache: yes
18+
when: ansible_distribution == "Ubuntu"
19+
20+
- name: "Add Kubernetes repository and install gpg key (CentOS)"
21+
yum_repository:
22+
name: kubernetes
23+
description: Kubernetes repository
24+
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
25+
gpgcheck: yes
26+
enabled: yes
27+
repo_gpgcheck: yes
28+
gpgkey: https://packages.cloud.google.com/yum/doc/yum-key.gpg
29+
when: ansible_distribution == "CentOS"
30+
31+
- name: "Disable SELinux (CentOS)"
32+
selinux:
33+
state: disabled
34+
when: ansible_distribution == "CentOS"
35+
36+
- name: "Install kubelet,kubeadm,kubectl (CentOS)"
37+
yum: state=present name={{ item }}
38+
with_items:
39+
- kubelet
40+
- kubeadm
41+
- kubectl
42+
when: ansible_distribution == "CentOS"
43+
44+
- name: "Install kubelet, kubeadm, kubectl (Ubuntu)"
45+
apt: name={{item}} state=installed
46+
with_items:
47+
- kubelet
48+
- kubeadm
49+
- kubectl
50+
when: ansible_distribution == "Ubuntu"

contrib/ansible/vars/vars.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# TODO update official versions once they are available
3+
cri_containerd_release_version: 0.1.0-234-g55a0887
4+
cri_release_directory: /opt/cri-containerd/
5+
local_bin_dir: /usr/local/bin/
6+
local_sbin_dir: /usr/local/sbin/
7+
cni_bin_dir: /opt/cni/bin/
8+
cni_conf_dir: /etc/cni/net.d/

contrib/systemd-units/containerd.service

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ Documentation=https://containerd.io
44
After=network.target
55

66
[Service]
7-
Restart=always
8-
RestartSec=10
7+
ExecStartPre=/sbin/modprobe overlay
98
ExecStart=/usr/local/bin/containerd
9+
Restart=always
10+
RestartSec=5
1011
Delegate=yes
1112
KillMode=process
13+
OOMScoreAdjust=-999
1214

1315
[Install]
1416
WantedBy=multi-user.target

contrib/systemd-units/cri-containerd.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=containerd.service
55

66
[Service]
77
Restart=always
8-
RestartSec=10
8+
RestartSec=5
99
ExecStart=/usr/local/bin/cri-containerd --logtostderr
1010
OOMScoreAdjust=-999
1111

0 commit comments

Comments
 (0)
X Tutup