487. 【kubernetes】二进制方式安装-containerd

该文介绍了如何在kubernetes1.25版本中,由于docker被弃用,转而使用containerd作为容器运行时环境来搭建集群。步骤包括下载并安装containerd,设置开机启动,安装runc,cni插件和nerdctl,以及展示如何使用containerd运行容器和验证其功能。

kubernetes 1.20 版本宣布弃用docker,kubernetes 1.24 版本正式移除docker,本着开发人员对于新技术的探索精神(作死精神),这篇开始基于 kubernetes 1.25 版本搭建集群。想要搭建包含docker版本的kubernetes集群的同学,可以移步文章末尾,查看七镜之前写的相关文章。

一、github中的containerd下载地址

点击下载:containerd-1.6.9-linux-amd64.tar.gz

二、解压安装 containerd

[root@k8s_master k8s]#  tar -zxvf containerd-1.6.9-linux-amd64.tar.gz 
bin/
bin/ctr
bin/containerd
bin/containerd-shim
bin/containerd-stress
bin/containerd-shim-runc-v2
bin/containerd-shim-runc-v1
[root@k8s_master k8s]#  cp bin/* /usr/local/bin/

三、开机自动启动

编辑 service 文件

vim /usr/lib/systemd/system/containerd.service

文件内容如下:

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
# uncomment to enable the experimental sbservice (sandboxed) version of containerd/cri integration
# Environment="ENABLE_CRI_SANDBOXES=sandboxed"
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

启动 containerd:

[root@k8s_master local]#  systemctl daemon-reload
[root@k8s_master local]#  systemctl enable --now containerd
[root@k8s_master local]#  s
根据我的环境,我适合那种部署?根据环境输出完整更新后的loki-values.yaml 环境虚拟机,kubernetes集群。 master 192.168.1.10 2核4G Addresses InternalIP: 192.168.1.10 Hostname: master OS:linux (amd64) OS Image:Rocky Linux 8.6 (Green Obsidian) Kernel version:4.18.0-372.9.1.el8.x86_64 Container runtime:containerd://1.6.12 Kubelet version:v1.26.0 Taints:node-role.kubernetes.io/control-plane:NoSchedule node1~4 192.168.1.11~14 2核2G Addresses InternalIP: 192.168.1.11~14 Hostname: node1~4 OS:linux (amd64) OS Image:Rocky Linux 8.6 (Green Obsidian) Kernel version:4.18.0-372.9.1.el8.x86_64 Container runtime:containerd://1.6.12 Kubelet version:v1.26.0 [root@master ~]# kubectl get nodes -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME master Ready control-plane 71d v1.26.0 192.168.1.10 <none> Rocky Linux 8.6 (Green Obsidian) 4.18.0-372.9.1.el8.x86_64 containerd://1.6.12 node1 Ready <none> 71d v1.26.0 192.168.1.11 <none> Rocky Linux 8.6 (Green Obsidian) 4.18.0-372.9.1.el8.x86_64 containerd://1.6.12 node2 Ready <none> 71d v1.26.0 192.168.1.12 <none> Rocky Linux 8.6 (Green Obsidian) 4.18.0-372.9.1.el8.x86_64 containerd://1.6.12 node3 Ready <none> 14d v1.26.0 192.168.1.13 <none> Rocky Linux 8.6 (Green Obsidian) 4.18.0-372.9.1.el8.x86_64 containerd://1.6.12 node4 Ready <none> 14d v1.26.0 192.168.1.14 <none> Rocky Linux 8.6 (Green Obsidian) 4.18.0-372.9.1.el8.x86_64 containerd://1.6.12 [root@master ~]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS master Ready control-plane 71d v1.26.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=master,kubernetes.io/os=linux,minio=true,node-role.kubernetes.io/control-plane=,node.kubernetes.io/exclude-from-external-load-balancers= node1 Ready <none> 71d v1.26.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node1,kubernetes.io/os=linux,minio=true node2 Ready <none> 71d v1.26.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node2,kubernetes.io/os=linux,minio=true node3 Ready <none> 14d v1.26.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node3,kubernetes.io/os=linux node4 Ready <none> 14d v1.26.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node4,kubernetes.io/os=linux
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值