🕸 kubectl-images 简介

kubectl-images 是一个 kubectl 插件,可以显示集群中使用的容器镜像。

kubectl-images使用该kubectl命令。它首先调用kubectl get pods以检索Pod的详细信息,并过滤出每个Pod的容器图像信息,然后在表格视图中打印出最终结果。

🔰 安装

Krew 方式安装

$ kubectl krew install images
Updated the local copy of plugin index.
Installing plugin: images
Installed plugin: images
\
 | Use this plugin:
 | 	kubectl images
 | Documentation:
 | 	https://github.com/chenjiandongx/kubectl-images
/

从源码构建

$ git clone https://github.com/chenjiandongx/kubectl-images.git
$ cd kubectl-images && go build -ldflags="-s -w" -o kubectl-images . && mv ./kubectl-images /usr/local/bin
$ kubectl images --help

下载二进制文件

export VERSION=0.3.0

# Linux
$ curl -Lo kubectl-images https://github.com/chenjiandongx/kubectl-images/releases/download/v${VERSION}/kubectl-images_linux_amd64
# MacOS
$ curl -Lo kubectl-images https://github.com/chenjiandongx/kubectl-images/releases/download/v${VERSION}/kubectl-images_darwin_amd64
# Windows
$ curl -Lo kubectl-images https://github.com/chenjiandongx/kubectl-images/releases/download/v${VERSION}/kubectl-images_windows_amd64

$ chmod +x kubectl-images && mv kubectl-images /usr/local/bin/
$ kubectl images --help

📝 用法

~ 🐶 kubectl images --help
Show container images used in the cluster.

Usage:
  kubectl-images [podname-regex] [flags]

例子:
  # 使用podName / containerName / containerImage作为列显示当前名称空间中所有图像的表。
  kubectl images

  # 使用podName / containerImage作为列,在'dev'名称空间中显示与'nginx'podname regex匹配的图像表。
  kubectl images -n dev nginx -c 1,2

Flags:
  -A, --all-namespaces     if present, list images in all namespaces.
  -c, --columns string     specify the columns to display, separated by comma. [0:Namespace, 1:PodName, 2:ContainerName, 3:ContainerImage] (default "1,2,3")
  -h, --help               help for kubectl-images
  -k, --kubeconfig string  path to the kubeconfig file to use for CLI requests.
  -n, --namespace string   if present, list images in the specified namespace only. Use current namespace as fallback.
      --version            version for kubectl-images

🔖 输出信息

image
image

📃 GitHub项目地址

GitHub传送门


 目录