Installing containerd
https://github.com/containerd/containerd/releases
1 | $ tar -zxvf ../containerd-1.6.19-linux-amd64.tar.gz |
Warning: Permanently added ‘k8s01,192.168.122.11’ (ECDSA) to the list of known hosts.
containerd 100% 50MB 172.4MB/s 00:00
containerd-shim 100% 7180KB 167.3MB/s 00:00
containerd-shim-runc-v1 100% 9248KB 161.9MB/s 00:00
containerd-shim-runc-v2 100% 9264KB 169.7MB/s 00:00
containerd-stress 100% 22MB 146.9MB/s 00:00
ctr 100% 26MB 193.4MB/s 00:00
containerd.service
/usr/local/lib/systemd/system/containerd.service
1 | cat <<EOF >/etc/systemd/system/containerd.service |
Delegate
: 这个选项允许 containerd 以及运行时自己管理自己创建容器的 cgroups。如果不设置这个选项,systemd 就会将进程移到自己的 cgroups 中,从而导致 containerd 无法正确获取容器的资源使用情况。KillMode
这个选项用来处理 containerd 进程被杀死的方式。默认情况下,systemd 会在进程的 cgroup 中查找并杀死 containerd 的所有子进程。KillMode 字段可以设置的值如下。control-group
(默认值):当前控制组里面的所有子进程,都会被杀掉process
:只杀主进程,可以确保升级或重启 containerd 时不杀死现有的容器mixed
:主进程将收到 SIGTERM 信号,子进程收到 SIGKILL 信号none
:没有进程会被杀掉,只是执行服务的 stop 命令
config.toml
/etc/containerd/config.toml
1 | containerd config default > ../containerd/config.toml |
Warning: Permanently added ‘k8s01,192.168.122.11’ (ECDSA) to the list of known hosts.
config.toml 100% 7154 6.8MB/s 00:00
pause
sandbox_image = “k8s.org/k8s/pause:3.6”
Systemd
[plugins.”io.containerd.grpc.v1.cri”.containerd.runtimes.runc.options]
1 | SystemdCgroup = true |
配置源
[plugins.”io.containerd.grpc.v1.cri”.registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.org"]
endpoint = ["https://k8s.org"]
https://github.com/containerd/containerd/blob/main/docs/cri/config.md
1 | cat > hosts.toml <<EOF |
https://github.com/containerd/containerd/blob/main/docs/hosts.md
kata
1 | ... |
1 | ctr run --runtime "io.containerd.kata.v2" --rm -t busybox:latest test-kata uname -r |
启动
1 | systemctl daemon-reload && systemctl restart containerd.service |
ctr
1 | # ctr ns ls |
x509 报错
1 | # ctr i pull k8s.org/k8s/pause:3.9 -k |
k8s.org/k8s/pause:3.9: resolved |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:0fc1f3b764be56f7c881a69cbd553ae25a2b5523c6901fbacb8270307c29d0c4: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:61fec91190a0bab34406027bbec43d562218df6e80d22d4735029756f23c7007: done |++++++++++++++++++++++++++++++++++++++|
config-sha256:e6f1816883972d4be47bd48879a08919b96afcd344132622e4d444987919323c: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 1.9 s total: 0.0 B (0.0 B/s)
unpacking linux/amd64 sha256:0fc1f3b764be56f7c881a69cbd553ae25a2b5523c6901fbacb8270307c29d0c4…
done: 430.599969ms
1 | # ctr i ls |
REF TYPE DIGEST SIZE PLATFORMS LABELS
k8s.org/k8s/pause:3.9 application/vnd.docker.distribution.manifest.v2+json sha256:0fc1f3b764be56f7c881a69cbd553ae25a2b5523c6901fbacb8270307c29d0c4 311.6 KiB linux/amd64 -
rm
1 | # ctr i rm registry.aliyuncs.com/google_containers/pause:3.6 |
crictl
https://github.com/kubernetes-sigs/cri-tools/releases
1 | cat > ./crictl.yaml <<EOF |
1 | tar -zxvf ../crictl-v1.26.0-linux-amd64.tar.gz |
Warning: Permanently added ‘k8s01,192.168.122.11’ (ECDSA) to the list of known hosts.
crictl 100% 50MB 172.6MB/s 00:00
1 | ❯ sudo crictl version |
containerd config default > /etc/containerd/config.toml
gid=xxx 添加组,普通用户使用
Installing runc
https://github.com/opencontainers/runc/releases
1 | $ scp runc.amd64 root@k8s01:/opt |
Warning: Permanently added ‘k8s01,192.168.122.11’ (ECDSA) to the list of known hosts.
runc.amd64 100% 9210KB 146.6MB/s 00:00
1 | # install -m 755 runc.amd64 /usr/local/sbin/runc |
Installing CNI plugins
1 | tar -zxvf ../cni-plugins-linux-amd64-v1.2.0.tgz -C ./cni/bin |
Warning: Permanently added ‘k8s01,192.168.122.11’ (ECDSA) to the list of known hosts.
ptp 100% 4064KB 121.7MB/s 00:00
vlan 100% 3900KB 175.7MB/s 00:00
tuning 100% 3357KB 168.7MB/s 00:00
macvlan 100% 3935KB 165.2MB/s 00:00
bandwidth 100% 3769KB 171.7MB/s 00:00
loopback 100% 3274KB 169.4MB/s 00:00
bridge 100% 4198KB 164.9MB/s 00:00
dhcp 100% 9929KB 176.3MB/s 00:00
portmap 100% 3658KB 169.1MB/s 00:00
ipvlan 100% 3906KB 128.2MB/s 00:00
firewall 100% 4282KB 127.3MB/s 00:00
host-device 100% 3780KB 160.8MB/s 00:00
dummy 100% 3893KB 162.8MB/s 00:00
host-local 100% 3210KB 160.2MB/s 00:00
sbr 100% 3467KB 167.2MB/s 00:00
static 100% 2779KB 161.2MB/s 00:00
vrf 100% 3502KB 166.9MB/s 00:00
level=error msg=”failed to load cni during init, please check CRI plugin status before setting up network for pods” error=”cni config load failed: no network config found in /etc/cni/net.d: cni plugin not initialized: failed to load cni config”
ERROR
containerd 启动不了
1 | systemctl restart containerd.service |
重点关注尝试 metadata.db 和 local-kv.db 这两个 db 文件。
存放的镜像数据,只是解决了启动,如何恢复????
containerd
1 | find /var/lib/containerd -type f -size -5M -name '*.db*' | grep -v overlay |
docker
1 | find /var/lib/docker -type f -size -5M -name '*.db*' | grep -v overlay |