containerd二进制安装

news/2024/9/19 18:42:42/ 标签: containerd, runc, cni

文章目录

  • 安装版本(在2024年9月10日是新版)
  • 方式1:yum安装(不推荐)
    • 设置主机名
    • 设置IP
    • 获取阿里YUM源
    • 查询containerd
    • 安装
    • 验证与启动服务
    • 测试命令
  • 方式2:二进制安装(推荐)
    • 安装之前先了解containerdcnirunc三者的关系
    • 设置主机名
    • 设置IP
    • 下载文件
    • containerd安装
      • 创建containerd服务
      • 将官方配置文件写入
      • 设置开机自启
    • runc安装
    • cni安装
    • 旧版本配置config.toml
      • 生成默认配置
      • 修改
    • 高版本hostpath问题
      • 生成默认配置文件
      • 创建镜像源配置文件
      • 设置配置文件位置
    • 重启启动
    • 测试
    • 成功

安装版本(在2024年9月10日是新版)

containerd 1.7.22

runc 1.1.12

cni 1.5.1

方式1:yum安装(不推荐)

设置主机名

hostnamectl set-hostname node1 

设置IP

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
重点设置以下几项

BOOTPROTO="static"
IPADDR=192.168.3.31
NETMASK=255.255.255.0
GATEWAY=192.168.3.1
DNS1=223.5.5.5

获取阿里YUM源

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

containerd_35">查询containerd

yum list | grep containerd

安装

yum install -y containerd.io

验证与启动服务

rpm -qa | grep containerd
systemctl enable containerd
systemctl start containerd
systemctl status containerd

测试命令

ctr version

方式2:二进制安装(推荐)

containerdcnirunc_64">安装之前先了解containerdcnirunc三者的关系

containerd 作为容器运行时,负责管理容器的生命周期和资源分配。它调用 RunC 来创建和运行容器,并通过调用 CNI 插件为容器配置网络。

54034d57ad166bcc91c0c0ec050995c9.png

设置主机名

hostnamectl set-hostname node1 

设置IP

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
重点设置以下几项

BOOTPROTO="static"
IPADDR=192.168.3.31
NETMASK=255.255.255.0
GATEWAY=192.168.3.1
DNS1=223.5.5.5

下载文件

containerd 1.7.22
runc 1.1.12
cni 1.5.1

containerd_94">containerd安装

$ tar Cxzvf /usr/local containerd-1.7.22-linux-amd64.tar.gz
bin/
bin/containerd-shim-runc-v2
bin/containerd-shim
bin/ctr
bin/containerd-shim-runc-v1
bin/containerd
bin/containerd-stress

containerd_105">创建containerd服务

mkdir -p /usr/local/lib/systemd/system/
touch /usr/local/lib/systemd/system/containerd.service
vim /usr/local/lib/systemd/system/containerd.service

将官方配置文件写入

官方配置文件

# 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/containerdType=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# 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

设置开机自启

systemctl daemon-reload
systemctl enable --now containerd

runc_162">runc安装

# runc安装
install -m 755 runc.amd64 /usr/local/sbin/runc

cni_169">cni安装

mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.5.1.tgz

旧版本配置config.toml

生成默认配置

mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
vim /etc/containerd/config.toml

修改

"https://xxxxxx.mirror.aliyuncs.com"自己登录阿里云换成自己的链接

# 原来是这样registry.k8s.io/pause:3.8
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.8"
# 原来是false
SystemdCgroup = true# 镜像配置
[plugins."io.containerd.grpc.v1.cri".registry.mirrors][plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]endpoint = ["https://xxxxxxxxx.mirror.aliyuncs.com"][plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]endpoint = ["registry.aliyuncs.com/google_containers"]
或者是这样
[plugins."io.containerd.grpc.v1.cri".registry.mirrors][plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]endpoint = ["https://xxxxxxxxx.mirror.aliyuncs.com","registry.aliyuncs.com/google_containers"]

高版本hostpath问题

WARN[0000] DEPRECATION: The `mirrors` property of `[plugins."io.containerd.grpc.v1.cri".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.1. Use `config_path` instead.

官方原文
原文解决方案链接

生成默认配置文件

mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
vim /etc/containerd/config.toml

创建镜像源配置文件

mkdir -p /etc/containerd/certs.d/docker.io/
mkdir -p /etc/containerd/certs.d/k8s.gcr.io/
cat<<EOF > /etc/containerd/certs.d/docker.io/hosts.toml
server = "https://docker.io"[host."https://xxxxxxxxx.mirror.aliyuncs.com"]capabilities = ["pull", "resolve"]
EOFcat<<EOF > /etc/containerd/certs.d/docker.io/hosts.toml
server = "https://docker.io"[host."registry.aliyuncs.com/google_containers"]capabilities = ["pull", "resolve"]
EOF

设置配置文件位置

[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/etc/containerd/certs.d"

51a05dfa81df2dec981cbb578d57dc21.png

重启启动

systemctl restart containerd
systemctl status containerd

测试

# docker.io
ctr images pull docker.io/library/ubuntu:latest
ctr images del docker.io/library/ubuntu:latest# k8s的镜像仓库叫k8s.gcr.io,没配镜像就要指定registry.cn-hangzhou.aliyuncs.com/google_containers
ctr images pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2
ctr images del registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2

成功

[root@node3 containerd]# ctr images pull docker.io/library/ubuntu:latest
docker.io/library/ubuntu:latest:                                                  resolved       |++++++++++++++++++++++++++++++++++++++|
index-sha256:8a37d68f4f73ebf3d4efafbcf66379bf3728902a8038616808f04e34a9ab63ee:    done           |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:d35dfc2fe3ef66bcc085ca00d3152b482e6cafb23cdda1864154caf3b19094ba: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:31e907dcc94a592a57796786399eb004dcbba714389fa615f5efa05a91316356:    done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:edbfe74c41f8a3501ce542e137cf28ea04dd03e6df8c9d66519b6ad761c2598a:   done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 9.9 s                                                                    total:  28.3 M (2.9 MiB/s)
unpacking linux/amd64 sha256:8a37d68f4f73ebf3d4efafbcf66379bf3728902a8038616808f04e34a9ab63ee...
done: 672.496318ms

http://www.ppmy.cn/news/1524182.html

相关文章

每周心赏|教师节“AI大礼包”:3款教学神器让你AI不释手

教师节“AI大礼包”真的来了&#xff01; 家人们谁懂啊&#xff0c;当学生时不想上课&#xff0c;当老师后不想上班…… 3款超会整活的教师必备AI神器&#xff0c;终于让我给挖到了&#xff1a;一键拥有金牌名师教学经验&#xff0c;助力撰写教案、高效赋能学生、总结工作成果…

流浪地球发动机

代码来自此处 if __name__ __main__:# 发动机的总个数, 计划手动启动的发动机总个数n, e map(int, input().split())# 记录每个发动机的最终启动时刻, 初始化为极大值&#xff0c;方便后面取最早启动时刻launches [1001] * nfor _ in range(e):# 发动机的手动启动时刻, 发动…

通信工程学习:什么是FDM频分复用、TDM时分复用、WDM波分复用、CDM码分复用

FDM频分复用、TDM时分复用、WDM波分复用、CDM码分复用 FDM频分复用、TDM时分复用、WDM波分复用、CDM码分复用是通信领域中常见的四种复用技术&#xff0c;它们各自具有不同的特点和应用场景。以下是对这四种复用技术的详细解释&#xff1a; 一、FDM频分复用&#xff08;Frequ…

Vue 中的 Vuex:全面解析与使用教程

什么是 Vuex&#xff1f; Vuex 是 Vue.js 官方提供的状态管理模式&#xff0c;专为 Vue.js 应用设计。它通过集中式存储管理应用中所有的组件状态&#xff0c;允许组件之间更方便地共享数据&#xff0c;并提供了一套规则来确保状态以可预测的方式发生变化。Vuex 对大型应用尤其…

Inspector里面可以编辑的变量相关

1.私有和保护变量无法在Inspector中编辑 2.给私有和保护变量加个特性[SerializeField]&#xff08;强制序列化字段特性&#xff09;就可以在inspector中看到和修改了 序列化就是把一个对象保存到一个文件或数据库字段中去 3.公共的也不让其显示编辑 给变量前加特性[HideInIn…

【Leetcode学习笔记】路径总和

【题目描述】给你二叉树的根节点 root 和一个表示目标和的整数 targetSum 。判断该树中是否存在 根节点到叶子节点 的路径&#xff0c;这条路径上所有节点值相加等于目标和 targetSum 。如果存在&#xff0c;返回 true &#xff1b;否则&#xff0c;返回 false 。 输入&#x…

Linux 信息安全:构建坚固的防御体系

摘要&#xff1a; 本文围绕 Linux 信息安全展开。阐述了 Linux 在信息技术中的重要地位&#xff0c;强调信息安全的重要性以及 Linux 信息安全面临复杂网络环境、演变攻击手段与内部威胁等挑战。详细介绍了 Linux 系统的安全架构与机制&#xff0c;包括用户与权限管理、文件系统…

HarmonyOS开发实战( Beta5.0)自定义组件冻结功能规范

自定义组件处于非激活状态时&#xff0c;状态变量将不响应更新&#xff0c;即Watch不会调用&#xff0c;状态变量关联的节点不会刷新。通过freezeWhenInactive属性来决定是否使用冻结功能&#xff0c;不传参数时默认不使用。支持的场景有&#xff1a;页面路由&#xff0c;TabCo…

vue3安装sass时报错:Embedded Dart Sass couldn‘t find the embedded compiler executable

vue3安装sass&#xff1a; npm install sass --save-dev 引用 <template><div class"c1"><h1>hello</h1></div> </template> <style lang"scss">.c1{background-color:red;h1{color:yellow;}} </style>报…

Nestjs微服务简单案例

相信大家&#xff0c;来看这篇博客&#xff0c;就应该知道微服务的概念。只是不太知道实用方法而已。下面我通过最简单的案例&#xff0c;来教会大家。 首先这是我的项目目录&#xff1a; nestwfw/ ├── app/ ├── project-microsericesapp 是web服务&#xff0c;用来接收…

HAL库学习目录查询表

日期内容2024.09.11基于STM32C8T6的CubeMX&#xff1a;HAL库点亮LED2024.09.11STMCuBeMX新建项目的两种匪夷所思的问题2024.09.11STMCubeMX文件下载后会出现其他项目无法下载的问题

如何在Vue实例上挂载自己定义的工具类

在实际的Vue开发中&#xff0c;我们经常需要在多个组件之间共享一些工具函数或类&#xff0c;比如格式化日期、处理字符串、操作数组等。这些工具类可以封装到一个独立的模块中&#xff0c;然后挂载到Vue实例上&#xff0c;方便在任何地方使用。本文将详细介绍如何在Vue实例上挂…

如何利用免费工具轻松设计出专业Logo?

Logo 作为品牌的象征和视觉核心&#xff0c;承载了品牌的价值和理念。无论是创业公司还是个人品牌&#xff0c;拥有一个独特的 Logo 都显得尤为重要。然而&#xff0c;设计一个专业的 Logo 通常需要高昂的设计费用&#xff0c;许多人因此望而却步。幸运的是&#xff0c;随着互联…

【平渊科技】项目拆解:小说推文项目 | 经验分享

目录 项目介绍 直接上操作教程 第一步&#xff1a;选文 第二步&#xff1a;改文 第三步&#xff1a;配音 第四步&#xff1a;剪辑 项目介绍 小说推文项目&#xff0c;可以说是市场上最常见的项目了。 我是去年十月份开始接触的&#xff0c;接触的比较晚了&#xff0c;我…

【H2O2|全栈】更多关于HTML(1)HTML进阶(一)

目录 HTML进阶知识 前言 准备工作 标签的扩展&#xff08;一&#xff09; 本文中的标签在什么位置使用&#xff1f; title标签 meta标签 name viewport referrer http-equiv charset content link标签 实际案例 可视部分 代码分析 其他标签 base标签 styl…

【Hot100算法刷题集】哈希-03-最长连续序列(含排序、哈希、并查集法未正确使用哈希表导致算法效率降低的分析)

&#x1f3e0;关于专栏&#xff1a;专栏用于记录LeetCode中Hot100专题的所有题目 &#x1f3af;每日努力一点点&#xff0c;技术变化看得见 题目转载 题目描述 &#x1f512;link->题目跳转链接 给定一个未排序的整数数组 nums &#xff0c;找出数字连续的最长序列&#x…

hiricacp 连接池校验机制

一、背景 项目发生告警&#xff0c;但是并没有影响业务&#xff0c;看了下日志&#xff0c;红框里面有循环调用了3次 &#xff0c;一直以为是外部的重试在重试&#xff0c;但是外部确没有重试记录&#xff0c;就深扒了代码 二、想法 我知道hikaricp获取连接之后会校验连接的有…

一文读懂在线学习凸优化技术

一文读懂在线学习凸优化技术 在当今的数据驱动时代&#xff0c;机器学习算法已成为解决复杂问题的关键工具。在线学习凸优化作为机器学习中的一项核心技术&#xff0c;不仅在理论研究上具有重要意义&#xff0c;还在实际应用中展现出巨大的潜力。本文将深入浅出地介绍在线学习…

【CanMV K230 AI视觉】 人体检测

【CanMV K230 AI视觉】 人体检测 人体检测 动态测试效果可以去下面网站自己看。 B站视频链接&#xff1a;已做成合集 抖音链接&#xff1a;已做成合集 人体检测 人体检测是判断摄像头画面中有无出现人体&#xff0c;常用于人体数量检测&#xff0c;人流量监控以及安防监控等。…

Windows下使用MinGW编译安装zmq的步骤

背景&#xff1a; 在开发过程中&#xff0c;需要使用zmq库进行数据交互&#xff0c;因此需要编译zmq库。 安装步骤 软件下载 https://github.com/zeromq/libzmq.git 下载&#xff0c;将代码切换到git checkout 4c6cff6391分支 软件编译 cd .\libzmq\ mkdir build cd .\bu…