系列文章目录
第一章 kubernetes1.24部署
第二章 选择docker作为容器运行时
第三章 选择containerd作为容器运行时
第四章 选择cri-o作为容器运行时
第五章 网络插件flannel部署
第六章 网络插件calico部署
第七章 网络插件cilium部署
选择cri-o作为kubernetes运行时
cri-o 实现了 kubernetes 的 Container Runtime Interface (CRI) 接口,提供容器运行时核心功能,如镜像管理、容器管理等,相比 docker 更加简单、健壮和可移植。
参考网址:cri-o
1. cri-o的安装
安装cri-o前,我们配置一下环境变量,以便于下面安装cri-o。
1.1根据自己的系统和要安装的cri-o版本来配置环境
我这里要安装的版本为1.24.1版本,cri-o和kubernetes的版本相对应 。可以查看官网来找到自己对应的环境设置参数:https://cri-o.io/
# export VERSION=1.24:1.24.1
# export OS=xUbuntu_20.04
查看操作系统命令:
# cat /etc/issue
官网参考如下:
1.2安装cri-o
- 写入存储库路径:
# echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
# echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
- 写入文件后,我们去
/etc/apt/sources.list.d/
路径下,找到devel:kubic:libcontainers:stable:cri-o:1.24:1.24.1.list
的文件,把里面的:
deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/1.24:1.24.1/xUbuntu_20.04/ /
//改为
deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/1.24:/1.24.1/xUbuntu_20.04/ /
示例如下:
因为我们这里下的是1.24的子版本1.24.1,官方在这里存储库设置的时候出了一点问题,修改后,存储库的路径就能正确寻找到1.24.1版本了。如果下载的1.24版本,则不需要修改。
- 下载密钥和安装:
# curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | apt-key add -
# curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -
# apt-get update
# apt-get install cri-o cri-o-runc
- 验证是否安装成功
# crio -v
//打印出版本信息则安装成功,示例如下
Version: 1.24.1
GitCommit: a3bbde8a77c323aa6a485da9a9046299155c6016
GitTreeState: clean
BuildDate: 2022-06-06T18:58:42Z
GoVersion: go1.18.2
Compiler: gc
Platform: linux/amd64
Linkmode: dynamic
BuildTags: apparmor, exclude_graphdriver_devicemapper, containers_image_ostree_stub, seccomp
SeccompEnabled: true
AppArmorEnabled: true
2.cri-o的配置
- 配置cri-o的网络代理
# mkdir -p /etc/systemd/system/crio.service.d/
# vim /etc/systemd/system/crio.service.d/http_proxy.conf
//写入如下内容
[Service]
Environment="HTTP_PROXY=http://**************************************"
Environment="HTTPS_PROXY=http://**************************************"
Environment="NO_PROXY=localhost,127.0.0.1,192.168.10.229,master2, "
//保存退出后
# systemctl daemon-reload
# systemctl start crio
# systemctl status crio
代理信息根据自身环境修改
启动成功参考:
3. 总结
cri-o作为kubernetes原生轻量级的运行时,安装和配置相对简单,对OCI容器也很好的兼容。
编辑时间:2022-8-19