Skip to content

Commit 965a56a

Browse files
committed
containerd
1 parent 2538afe commit 965a56a

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

scripts/installContainerd.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
install_ubuntu() {
4+
## Remove any pre installed containerd packages:
5+
which containerd
6+
if [ $? -eq 0 ];then
7+
systemctl stop containerd.service
8+
apt-get remove -y containerd
9+
apt-get purge -y containerd
10+
apt -y autoremove
11+
else
12+
echo "containerd is not installed.. continue to install"
13+
fi
14+
15+
## Install using the repository:
16+
apt-get update
17+
apt-get install -y containerd
18+
19+
if [ $? -eq 0 ];then
20+
echo "containerd is successfully installed"
21+
configure_contd
22+
else
23+
echo "issue with containerd installation - process abort"
24+
exit 1
25+
fi
26+
exit 0
27+
}
28+
29+
install_centos() {
30+
31+
which containerd
32+
if [ $? -eq 0 ];then
33+
yum remove -y containerd.io
34+
yum clean
35+
else
36+
echo "containerd is not installed... continue to install"
37+
fi
38+
yum install -y yum-utils ## device-mapper-persistent-data lvm2
39+
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
40+
yum install containerd.io -y
41+
if [ $? -eq 0 ];then
42+
echo "containerd is successfully installed"
43+
systemctl restart containerd ; clear
44+
configure_contd
45+
else
46+
echo "issue with containerd installation - process abort"
47+
exit 1
48+
fi
49+
}
50+
51+
configure_contd() {
52+
53+
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
54+
overlay
55+
br_netfilter
56+
EOF
57+
58+
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
59+
net.bridge.bridge-nf-call-iptables = 1
60+
net.bridge.bridge-nf-call-ip6tables = 1
61+
net.ipv4.ip_forward = 1
62+
EOF
63+
64+
sudo modprobe overlay
65+
sudo modprobe br_netfilter
66+
67+
#reload kernel config
68+
sudo sysctl --system
69+
# generate default containerd config
70+
mkdir -p /etc/containerd
71+
containerd config default | sudo tee /etc/containerd/config.toml
72+
sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml
73+
systemctl restart containerd
74+
75+
}
76+
################ MAIN ###################
77+
78+
if [ -f /etc/os-release ];then
79+
osname=`grep ID /etc/os-release | egrep -v 'VERSION|LIKE|VARIANT|PLATFORM' | cut -d'=' -f2 | sed -e 's/"//' -e 's/"//'`
80+
echo $osname
81+
if [ $osname == "ubuntu" ];then
82+
install_ubuntu
83+
elif [ $osname == "amzn" ];then
84+
install_centos
85+
elif [ $osname == "centos" ];then
86+
install_centos
87+
fi
88+
else
89+
echo "can not locate /etc/os-release - unable find the osname"
90+
exit 8
91+
fi
92+
exit 0

0 commit comments

Comments
 (0)