一键部署containerd的脚本,软件源通过官网下载,若通过wget下载失败,直接下载tar包上传运行脚本即可
#!/bin/bash
#wget https://github.com/containerd/containerd/releases/download/v1.7.13/cri-containerd-cni-1.7.13-linux-amd64.tar.gz
#if [ !$? = 0 ]; then
# echo "下载失败,稍后再来"
# exit
# fi
mkdir -p /oldboyedu/softwares/ &>/dev/null
sleep 1
tar xf cri-containerd-cni-1.7.13-linux-amd64.tar.gz -C /oldboyedu/softwares/ &>/dev/null
sleep 5
cp /oldboyedu/softwares/usr/local/bin/containerd /usr/local/bin/
cp /oldboyedu/softwares/etc/systemd/system/containerd.service /usr/lib/systemd/system/
cp /oldboyedu/softwares/usr/local/bin/ctr /usr/bin/
cp /oldboyedu/softwares/usr/local/bin/containerd-shim-runc-v2 /usr/bin/
mv runc.amd64 /usr/sbin/runc
chmod +x /usr/sbin/runc
mkdir /etc/containerd &>/dev/null
sleep 1
containerd config default > /etc/containerd/config.toml
sed -ri "s#(SystemdCgroup = )false#\1true#" /etc/containerd/config.toml
sed -i "s#registry.k8s.io/pause:3.8#registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.8#" /etc/containerd/config.toml
if [ $? = 0 ]; then
sed -i 's#mirrors#mirrors."harbor.oldboyedu.com"#g' /etc/containerd/config.toml
sed -i '/harbor.oldboyedu.com/a endpoint = [ "http://harbor.oldboyedu.com" ]' /etc/containerd/config.toml
else
echo "文件配置失败,请重试"
fi
systemctl enable --now containerd &>/dev/null
sleep 1
systemctl status containerd &>/dev/null
if [ $? = 0 ];then
echo "启动成功"
exit
else
echo "启动失败"
fi