containerd一键安装脚本


Ubuntu 18.04.6TLS一键安装containerd脚本

#!/bin/bash
#Auth Eddie.Peng

#加载k8s所需的内核模块
sudo cat > /etc/modules-load.d/kubernetes.conf < /etc/sysctl.d/kubernetes.conf < /etc/containerd/config.toml

#设置k8s镜像使用阿里云镜像源
sed -i "s#k8s.gcr.io#registry.cn-hangzhou.aliyuncs.com/google_containers#g"  /etc/containerd/config.toml
#设置docker镜像源使用阿里云镜像源
sed -i "s#https://registry-1.docker.io#https://registry.cn-hangzhou.aliyuncs.com#g"  /etc/containerd/config.toml
#设置 runc 使用 systemdcgroup 驱动
sed -i '/containerd.runtimes.runc.options/a\ \ \ \ \ \ \ \ \ \ \ \ SystemdCgroup = true' /etc/containerd/config.toml

#重启containerd服务
systemctl daemon-reload
systemctl enable containerd
systemctl restart containerd

#设置containerd作为k8s默认的容器运行时
crictl config runtime-endpoint /run/containerd/containerd.sock