containerd的安装和配置
配置yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
containerd安装
yum install containerd jq -y
jq是什么?
jq可以对json数据进行分片、过滤、映射和转换,和sed、awk、grep等命令一样,都可以让你轻松地把玩文本。它能轻松的把你拥有的数据转换成你期望的格式,而且需要写的程序通常也比你期望的更加简短。
jq是用C编写,没有运行时依赖,所以几乎可以运行在任何系统上。预编译的二进制文件可以直接在Linux、OS X和windows系统上运行,当然在linux和OS x系统你需要赋予其可执行权限;在Linux系统中也可以直接用yum安装。
download
在知道jq命令之前,我在linux系统中极少直接去命令处理json数据,除非只是简单的从中过滤某个字符串,那就用grep结合正则表达式来解决。所以,掌握了jq命令,则可以让Linux命令和shell脚本在处理json数据时变得得心应手。
jq简明教程
例子文件:
为了便于演示jq的功能,我们在文件json.txt中保存内容如下:
cat json.txt
[{“name”:“站长工具”,“url”:“http://tool.china.com”,“address”:{“city”:“广东”,“country”:“中国”},“arrayBrowser”:[{“name”:“Google”,“url”:“http://www.google.com”},{“name”:“Baidu”,“url”:“http:///www.baidu.com”}]},{“name”:“站长之家”,“url”:“http://tool.zzhome.com”,“address”:{“city”:“北京”,“country”:“中国”},“arrayBrowser”:[{“name”:“360”,“url”:“http://www.so.com”},{“name”:“bing”,“url”:“http://www.bing.com”}]}]
cat json.txt | jq ‘.’
初始化Containerd配置:
containerd config default > /etc/containerd/config.toml
systemctl enable --now containerd
替换containerd默认的sand_box 镜像,编辑/etc/containerd/config.toml文件:
sandbox_image = "k8s.gcr.io/pause:3.2"替换成registry.cn-hanzhou.aliyuncs.com/google-containers/pause-amd64:3.2
应用配置并重新运行containerd服务
systemctl daemon-reload
systemctl restart containerd
systemctl status containerd