(8)k8s使用containerd

创建相关目录

# 所有节点
mkdir -p /etc/cni/net.d
mkdir -p /opt/cni/bin

后续calicoflannel网络组件也会创建相关的文件夹

安装网络插件

cd /opt/k8s-playbook
tar -zxvf -C /opt/cni/bin

scp /opt/cni/bin/* root@master-02:/opt/cni/bin/
scp /opt/cni/bin/* root@master-03:/opt/cni/bin/
scp /opt/cni/bin/* root@node-01:/opt/cni/bin/
scp /opt/cni/bin/* root@node-02:/opt/cni/bin/

安装cri组件

包括containerd, containerd-shim, runc

yum install containerd.io

如果找不到安装包, 请参照我之前的文章配置最新的yum源: docker快速安装

编辑containerd的配置文件

vi /etc/containerd/config.toml
####################################
[plugins]
  [plugins.cri]
    sandbox_image = "rancher/pause:3.1"
    [plugins.cri.cni]
      bin_dir = "/opt/cni/bin"
      conf_dir = "/etc/cni/net.d"
    [plugins.cri.registry]
      [plugins.cri.registry.mirrors]
        [plugins.cri.registry.mirrors."docker.io"]
          endpoint = ["https://docker.mirrors.ustc.edu.cn"]
  [plugins.linux]
    shim = "containerd-shim"
    runtime = "runc"
    runtime_root = ""
    no_shim = false
    shim_debug = false

注释配置文件中的disabled_plugins = ["cri"]或删掉

  • sandbox_image: 沙箱镜像
  • bin_dir: 网络插件可执行程序
  • conf_dir: 网络插件配置文件
  • endpoint: 指定拉取镜像地址, 这里使用中科大的镜像站

分发

scp /etc/containerd/config.toml root@master-02:/etc/containerd/
scp /etc/containerd/config.toml root@master-03:/etc/containerd/
scp /etc/containerd/config.toml root@node-01:/etc/containerd/
scp /etc/containerd/config.toml root@node-02:/etc/containerd/

启动程序

systemctl start containerd

安装crictl管理工具

复制二进制文件

cd /opt/k8s-playbook/
tar -zxvf crictl-v1.19.0-linux-amd64.tar.gz /opt/k8s/bin/

编辑配置文件

vi /etc/crictl.yaml
####################################
runtime-endpoint: unix:///var/run/containerd/containerd.sock
image-endpoint: unix:///var/run/containerd/containerd.sock
timeout: 10
debug: false

检测containerd环境

cricrtl info
展示评论