k8s系列-05-k8s集群搭建方案对比,以及containerd是什么,如何安装
主旨
可选方案 |
方案来源 | 易难度 |
高可用 |
部署方式 |
kubeadm |
官方 |
适中 | 自定义 | 容器 |
kubespray |
官方 | 简单 | 生产级 |
容器 |
kubernetes-the-hard-way | 社区 |
困难 | 自定义 |
二进制 |
containerd
containerd is available as a daemon for Linux and Windows. It manages the complete container lifecycle of its host system, from image transfer and storage to container execution and supervision to low-level storage to network attachments and beyond.
Containerd 负责干下面这些事情:
•管理容器的生命周期(从创建容器到销毁容器)
•拉取/推送容器镜像
•存储管理(管理镜像及容器数据的存储)
•调用 runC 运行容器(与 runC 等容器运行时交互)
•管理容器网络接口及网络
注意:Containerd 被设计成嵌入到一个更大的系统中,而不是直接由开发人员或终端用户使用。
我们可以从下面几点来理解为什么需要独立的 containerd:
•继续从整体 docker 引擎中分离出的项目(开源项目的思路)
•可以被 Kubernets CRI 等项目使用(通用化)
•为广泛的行业合作打下基础(就像 runC 一样)
首先我们登录github官网上,可以看到截止今日最新版本是1.6.1,咱们这里就根据这个版本来进行安装。
[yunweijia@localhost ~]$ mkdir containerd
[yunweijia@localhost ~]$ cd containerd/
# 上传软件包
[yunweijia@localhost containerd]$ ls
cri-containerd-1.6.1-linux-amd64.tar.gz
[yunweijia@localhost containerd]$
解压:
[yunweijia@localhost containerd]$ tar xf cri-containerd-1.6.1-linux-amd64.tar.gz
[yunweijia@localhost containerd]$ ls
cri-containerd-1.6.1-linux-amd64.tar.gz etc opt usr
[yunweijia@localhost containerd]$
删除一些我们不需要的内容:
[yunweijia@localhost containerd]$ rm -rf opt/
拷贝:
[yunweijia@localhost containerd]$ sudo cp -r etc /
[yunweijia@localhost containerd]$ sudo cp -r usr /
生成默认的配置文件,不知道为啥sudo报错没权限,我直接切换到了root用户进行该操作:
[yunweijia@localhost containerd]$ su root
密码:
[root@localhost containerd]#
[root@localhost containerd]# containerd config default > /etc/containerd/config.toml
[root@localhost containerd]# exit
exit
[yunweijia@localhost containerd]$
开启自启动并重启:
[yunweijia@localhost containerd]$ sudo systemctl enable containerd
Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /etc/systemd/system/containerd.service.
[yunweijia@localhost containerd]$ sudo systemctl restart containerd
[yunweijia@localhost containerd]$
[yunweijia@localhost containerd]$ sudo systemctl status containerd
● containerd.service - containerd container runtime
Loaded: loaded (/etc/systemd/system/containerd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2022-03-07 11:38:41 CST; 1min 44s ago
Docs: https://containerd.io
Process: 38862 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 38864 (containerd)
Tasks: 8
Memory: 47.3M
CGroup: /system.slice/containerd.service
└─38864 /usr/local/bin/containerd
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.713543190+08:00" level=error msg="failed to load cni during init, please che...i config"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.713701928+08:00" level=info msg=serving... address=/run/containerd/containerd.sock.ttrpc
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.713726263+08:00" level=info msg=serving... address=/run/containerd/containerd.sock
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.713760788+08:00" level=info msg="containerd successfully booted in 0.077920s"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730233904+08:00" level=info msg="Start subscribing containerd event"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730310137+08:00" level=info msg="Start recovering state"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730404474+08:00" level=info msg="Start event monitor"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730417359+08:00" level=info msg="Start snapshots syncer"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730425694+08:00" level=info msg="Start cni network conf syncer for default"
3月 07 11:38:41 localhost.localdomain containerd[38864]: time="2022-03-07T11:38:41.730432477+08:00" level=info msg="Start streaming server"
Hint: Some lines were ellipsized, use -l to show in full.
[yunweijia@localhost containerd]$
至此,搭建完毕,下一篇我们将介绍如何使用containerd。