快速安装containerd和nerdctl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Download
# 版本灵活变动
export CONTAINERD_VERSION=1.7.13
export CNI_PLUGIN_VERSION=v1.4.0
export RUNC_VERSION=v1.1.11
export NERDCTL_VERSION=1.7.4

wget "https://github.com/containerd/containerd/releases/download/v$CONTAINERD_VERSION/containerd-v$CONTAINERD_VERSION-linux-amd64.tar.gz"
wget "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGIN_VERSION/cni-plugins-linux-amd64-$CNI_PLUGIN_VERSION.tgz"
wget "https://github.com/opencontainers/runc/releases/download/$RUNC_VERSION/runc.amd64"
wget "https://github.com/containerd/nerdctl/releases/download/v$NERDCTL_VERSION/nerdctl-$NERDCTL_VERSION-linux-amd64.tar.gz"

# Install
tar -Czvxf /usr/local/bin containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz
mv /usr/local/bin/bin/* /usr/local/bin/ && rm -rf /usr/local/bin/bin
mkdir -p /opt/cni/bin && tar Czvxf /opt/cni/bin cni-plugins-linux-amd64-$CNI_PLUGIN_VERSION.tgz
chmod 755 runc.amd64 && mv runc.amd64 /usr/local/bin/runc
tar Czvxf /usr/local/bin nerdctl-$NERDCTL_VERSION-linux-amd64.tar.gz

# Config
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
vim /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://k8s-gcr.m.daocloud.io"]
...

# Enable
# cp https://github.com/containerd/containerd/blob/v$CONTAINERD_VERSION/containerd.service to /etc/systemd/system/containerd.service
systemctl daemon-reload
systemctl enable containerd --now

# Test
nerdctl info