crictl 命令 - Kubernetes 管理命令详解

描述:crictl 是 CRI 兼容的容器运行时命令行对接客户端, 你可以使用它来检查和调试 Kubernetes 节点上的容器运行时和应用程序。由于该命令是为k8s通过CRI使用containerd而开发的(主要是调试工具), 其他非k8s的创建的 crictl 是无法看到和调试的, 简单的说用 ctr run 运行的容器无法使用 crictl 看到。

Tips: crictl 命令工具 和 它的源代码在 cri-tools 代码库。
Tips: crictl 默认使用命名空间 k8s.io.
Tips: cri plugin区别对待pod和container

基础配置

描述: 在 k8s 1.19.x 之前 crictl 默认连接到 unix:///var/run/dockershim.sock,而在1.20.x起默认采用 /run/containerd/containerd.sock 运行时,当然除此之外还是支持cri-o运行时。

# crictl by default connects on Unix to:
unix:///var/run/dockershim.sock or
unix:///run/containerd/containerd.sock or
unix:///run/crio/crio.sock

# or on Windows to:
npipe:////./pipe/dockershim or
npipe:////./pipe/containerd or
npipe:////./pipe/crio

# For other runtimes, use:
frakti: unix:///var/run/frakti.sock

查看或编辑 /etc/crictl.yaml 的内容并设置指定的容器运行时runtime。

$ cat /etc/crictl.yaml
runtime-endpoint: /run/containerd/containerd.sock
image-endpoint: "/run/containerd/containerd.sock"
timeout: 0
debug: false
pull-image-on-create: false

Tips: 除了上面的设置端点外,我们还可以利用其它方式进行临时设置或者指定配置文件。

# 1.通过在配置文件中设置端点并通过 --config 参数指定配置文件
crictl --config=/etc/crictl-demo.yaml

# 2.通过设置参数 --runtime-endpoint 和 --image-endpoint
crictl --runtime-endpoint="/run/containerd/containerd.sock" --image-endpoint="/run/containerd/containerd.sock"
posted @   哈喽哈喽111111  阅读(3407)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2021-07-06 nginx进程所属用户问题讨论
点击右上角即可分享
微信分享提示