【kubernetes】二进制方式安装 containerd

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: 【kubernetes】二进制方式安装 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]# systemctl status containerd
● containerd.service - containerd container runtime
   Loaded: loaded (/usr/lib/systemd/system/containerd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-11-13 05:54:39 PST; 8s ago
     Docs: https://containerd.io
  Process: 4621 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
 Main PID: 4623 (containerd)
    Tasks: 11
   Memory: 19.8M
   CGroup: /system.slice/containerd.service
           └─4623 /usr/local/bin/containerd
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.278882504-08:00" level=info msg="Start subscribing containerd event"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.278953951-08:00" level=info msg="Start recovering state"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279008746-08:00" level=info msg="Start event monitor"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279022071-08:00" level=info msg="Start snapshots syncer"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279030108-08:00" level=info msg="Start cni network conf syn...efault"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279034770-08:00" level=info msg="Start streaming server"
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279331034-08:00" level=info msg=serving... address=/run/con...k.ttrpc
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279373899-08:00" level=info msg=serving... address=/run/con...rd.sock
Nov 13 05:54:39 k8s_master containerd[4623]: time="2022-11-13T05:54:39.279859901-08:00" level=info msg="containerd successfully bo...26879s"
Nov 13 05:54:39 k8s_master systemd[1]: Started containerd container runtime.
Hint: Some lines were ellipsized, use -l to show in full.

可以看已经正常运行了。


四、解压安装 runc


下载地址:runc.amd64

安装命令:install -m 755 runc.amd64 /usr/local/sbin/runc


五、解压安装 cni


下载地址:cni-plugins-linux-amd64-v1.1.1.tgz

安装命令:

[root@k8s_master k8s]# mkdir -p /opt/cni/bin
[root@k8s_master k8s]# tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz
./
./macvlan
./static
./vlan
./portmap
./host-local
./vrf
./bridge
./tuning
./firewall
./host-device
./sbr
./loopback
./dhcp
./ptp
./ipvlan
./bandwidth


六、解压安装 nerdctl


下载地址:nerdctl-1.0.0-linux-amd64.tar.gz

tar -zxvf nerdctl-1.0.0-linux-amd64.tar.gz
cp nerdctl /usr/bin/


七、containerd 初体验


  1. 下载镜像

ctr images pull docker.io/library/redis:alpine

0000.webp.jpg

下载镜像


2.运行容器(redis实例)

[root@k8s_master k8s]# nerdctl run -it -p 6379:6379 --name redis redis:alpine
1:C 13 Nov 2022 14:52:23.234 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 13 Nov 2022 14:52:23.234 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 13 Nov 2022 14:52:23.234 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 13 Nov 2022 14:52:23.235 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 13 Nov 2022 14:52:23.235 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 13 Nov 2022 14:52:23.235 # Current maximum open files is 1024. maxclients has been reduced to 992 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 13 Nov 2022 14:52:23.235 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'    
1:M 13 Nov 2022 14:52:23.236 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 13 Nov 2022 14:52:23.236 # Server initialized
1:M 13 Nov 2022 14:52:23.236 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 13 Nov 2022 14:52:23.236 * Ready to accept connections

---.webp.jpg

运行成功


  1. 验证
    通过redis 客户端连接试试:

    00.webp.jpg

验证成功


【附加】八、生成自定义配置

mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml


【附加】 九、安装 crictl


安装命令:

VERSION="v1.25.0"
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
rm -f crictl-$VERSION-linux-amd64.tar.gz


修改配置文件:

cat>/etc/crictl.yaml <<EOF
runtime-endpoint: unix:///var/run/containerd/containerd.sock
image-endpoint: unix:///var/run/containerd/containerd.sock
timeout: 10
debug: false
EOF

==.webp.jpg

安装成功


相关实践学习
深入解析Docker容器化技术
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙箱机制,相互之间不会有任何接口。Docker是世界领先的软件容器平台。开发人员利用Docker可以消除协作编码时“在我的机器上可正常工作”的问题。运维人员利用Docker可以在隔离容器中并行运行和管理应用,获得更好的计算密度。企业利用Docker可以构建敏捷的软件交付管道,以更快的速度、更高的安全性和可靠的信誉为Linux和Windows Server应用发布新功能。 在本套课程中,我们将全面的讲解Docker技术栈,从环境安装到容器、镜像操作以及生产环境如何部署开发的微服务应用。本课程由黑马程序员提供。 &nbsp; &nbsp; 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
目录
相关文章
|
7月前
|
人工智能 运维 Kubernetes
2025 超详细!Lens Kubernetes IDE 多平台下载安装与集群管理教程
Lens 是一款企业级 Kubernetes 可视化操作平台,2025版实现了三大技术革新:AI智能运维(异常检测准确率98.7%)、多云联邦管理(支持50+集群)和实时3D拓扑展示。本文介绍其安装环境、配置流程、核心功能及高阶技巧,帮助用户快速上手并解决常见问题。适用于 Windows、macOS 和 Ubuntu 系统,需满足最低配置要求并前置依赖组件如 kubectl 和 Helm。通过 Global Cluster Hub 实现多集群管理,AI辅助故障诊断提升运维效率,自定义监控看板和插件生态扩展提供更多功能。
|
10月前
|
Kubernetes 应用服务中间件 nginx
二进制安装Kubernetes(k8s)v1.32.0
本指南提供了一个详细的步骤,用于在Linux系统上通过二进制文件安装Kubernetes(k8s)v1.32.0,支持IPv4+IPv6双栈。具体步骤包括环境准备、系统配置、组件安装和配置等。
3251 11
|
Kubernetes Ubuntu Docker
从0开始搞K8S:使用Ubuntu进行安装(环境安装)
通过上述步骤,你已经在Ubuntu上成功搭建了一个基本的Kubernetes单节点集群。这只是开始,Kubernetes的世界广阔且深邃,接下来你可以尝试部署应用、了解Kubernetes的高级概念如Services、Deployments、Ingress等,以及探索如何利用Helm等工具进行应用管理,逐步提升你的Kubernetes技能树。记住,实践是最好的老师,不断实验与学习,你将逐渐掌握这一强大的容器编排技术。
2028 1
|
Kubernetes Linux 开发工具
centos7通过kubeadm安装k8s 1.27.1版本
centos7通过kubeadm安装k8s 1.27.1版本
|
Kubernetes Docker 容器
rancher docker k8s安装(二)
rancher docker k8s安装(二)
239 1
|
存储 Kubernetes 负载均衡
基于Ubuntu-22.04安装K8s-v1.28.2实验(四)使用域名访问网站应用
基于Ubuntu-22.04安装K8s-v1.28.2实验(四)使用域名访问网站应用
227 1
|
负载均衡 应用服务中间件 nginx
基于Ubuntu-22.04安装K8s-v1.28.2实验(二)使用kube-vip实现集群VIP访问
基于Ubuntu-22.04安装K8s-v1.28.2实验(二)使用kube-vip实现集群VIP访问
371 1
|
11月前
|
Kubernetes Ubuntu Linux
我应该如何安装Kubernetes
我应该如何安装Kubernetes
|
Kubernetes 网络协议 安全
[kubernetes]二进制方式部署单机k8s-v1.30.5
[kubernetes]二进制方式部署单机k8s-v1.30.5
|
Kubernetes 容器
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
567 0

热门文章

最新文章

推荐镜像

更多
下一篇
开通oss服务