【kubernetes】二进制方式安装 containerd

本文涉及的产品
云数据库 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

安装成功


相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
云原生实践公开课
课程大纲 开篇:如何学习并实践云原生技术 基础篇: 5 步上手 Kubernetes 进阶篇:生产环境下的 K8s 实践 相关的阿里云产品:容器服务&nbsp;ACK 容器服务&nbsp;Kubernetes&nbsp;版(简称&nbsp;ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情:&nbsp;https://www.aliyun.com/product/kubernetes
目录
相关文章
|
21天前
|
Kubernetes 网络协议 应用服务中间件
K8S二进制部署实践-1.15.5
K8S二进制部署实践-1.15.5
31 0
|
2月前
|
Kubernetes 数据安全/隐私保护 Docker
|
5天前
|
Kubernetes Linux 网络安全
kubeadm安装k8s
该文档提供了一套在CentOS 7.6上安装Docker和Kubernetes(kubeadm)的详细步骤,包括安装系统必备软件、关闭防火墙和SELinux、禁用swap、开启IP转发、设置内核参数、配置Docker源和加速器、安装指定版本Docker、启动Docker、设置kubelet开机启动、安装kubelet、kubeadm、kubectl、下载和配置Kubernetes镜像、初始化kubeadm、创建kubeconfig文件、获取节点加入集群命令、下载Calico YAML文件以及安装Calico。这些步骤不仅适用于v1.19.14,也适用于更高版本。
41 1
|
19天前
|
Kubernetes 安全 网络安全
搭建k8s集群kubeadm搭建Kubernetes二进制搭建Kubernetes集群
搭建k8s集群kubeadm搭建Kubernetes二进制搭建Kubernetes集群
101 0
|
23天前
|
Kubernetes 测试技术 API
ChaosBlade常见问题之安装K8S探针心跳检测失败如何解决
ChaosBlade 是一个开源的混沌工程实验工具,旨在通过模拟各种常见的硬件、软件、网络、应用等故障,帮助开发者在测试环境中验证系统的容错和自动恢复能力。以下是关于ChaosBlade的一些常见问题合集:
19 0
|
1月前
|
Kubernetes 应用服务中间件 nginx
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
34 5
|
1月前
|
存储 Kubernetes 监控
KubeSphere平台安装系列之一【Kubernetes上安装KubeSphere(亲测--实操完整版)】(1/3)
KubeSphere平台安装系列之一【Kubernetes上安装KubeSphere(亲测--实操完整版)】(1/3)
39 0
|
1月前
|
存储 Kubernetes 监控
K8S集群上安装KubeSphere的详细过程
K8S集群上安装KubeSphere的详细过程
26 0
|
1月前
|
Kubernetes Linux Docker
深度解析:Kubernetes 1.28.2集群安装过程中的关键步骤
本文旨在为读者提供一份详尽的Kubernetes 1.28.2集群安装指南,帮助您从零开始构建稳定、高效的Kubernetes集群。我们将从环境准备、软件安装、集群初始化到节点添加等各个环节进行逐步讲解,确保您能够顺利完成集群的搭建。
|
1月前
|
运维 Kubernetes API
kubernetes 安装 kubernetes-dashboard 7.x
kubernetes 安装 kubernetes-dashboard 7.x
36 0