基于kubernetes于1.24版本舍弃dockershim模块,此处将k8s的container runtime用containerd进行部署

[root@localhost ~]#wget https://github.com/opencontainers/runc/releases/download/v1.1.0/runc.amd64
[root@localhost ~]#mv runc.amd64 /usr/local/sbin/runc
[root@localhost ~]#chmod +x /usr/local/sbin/runc
[root@localhost ~]#wget https://github.com/containerd/containerd/releases/download/v1.5.9/containerd-1.5.9-linux-amd64.tar.gz
[root@localhost ~]#tar -zxvf containerd-1.5.9-linux-amd64.tar.gz
[root@localhost ~]#mv ./bin/* /usr/local/bin/
[root@localhost ~]#cat > /lib/systemd/system/containerd.service << EOF
>
> # Copyright The containerd Authors.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> # http://www.apache.org/licenses/LICENSE-2.0
> #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
>
> [Unit]
> Description=containerd container runtime
> Documentation=https://containerd.io
> After=network.target local-fs.target
>
> [Service]
> ExecStartPre=-/sbin/modprobe overlay
> ExecStart=/usr/local/bin/containerd
>
> Type=notify
> Delegate=yes
> KillMode=process
> Restart=always
> RestartSec=5
> # Having non-zero Limit*s causes performance problems due to accounting overhead
> # in the kernel. We recommend using cgroups to do container-local accounting.
> LimitNPROC=infinity
> LimitCORE=infinity
> LimitNOFILE=infinity
> # Comment TasksMax if your systemd version does not supports it.
> # Only systemd 226 and above support this version.
> TasksMax=infinity
> OOMScoreAdjust=-999
>
> [Install]
> WantedBy=multi-user.target
>
> EOF
[root@localhost ~]#mkdir -p /etc/containerd
[root@localhost ~]#containerd config default > /etc/containerd/config.toml
[root@localhost ~]#systemctl daemon-reload
[root@localhost ~]#systemctl start containerd.service
[root@localhost ~]#systemctl enable containerd.service
[root@localhost ~]#runc -v
runc version 1.1.0
commit: v1.1.0-0-g067aaf85
spec: 1.0.2-dev
go: go1.17.6
libseccomp: 2.5.3
[root@localhost ~]#ctr -v
ctr github.com/containerd/containerd v1.5.9
[root@localhost ~]#vim /etc/containerd/config.toml //修改sandbox镜像地址为国内镜像源
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.5"
[root@localhost ~]#systemctl daemon-reload
[root@localhost ~]#systemctl restart containerd.service
[root@localhost ~]#wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.23.0/crictl-v1.23.0-linux-amd64.tar.gz
[root@localhost ~]#tar zxvf crictl-v1.23.0-linux-amd64.tar.gz -C /usr/local/bin
[root@localhost ~]#vim /etc/crictl.yaml
runtime-endpoint: unix:///var/run/containerd/containerd.sock
image-endpoint: unix:///var/run/containerd/containerd.sock
debug: false
pull-image-on-create: false
disable-pull-on-run: false
[root@localhost ~]#crictl pull nginx
Image is up to date for sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
[root@localhost ~]#crictl images
IMAGE TAG IMAGE ID SIZE
docker.io/library/nginx latest 605c77e624ddb 56.7MB
1241

被折叠的 条评论
为什么被折叠?



