Giter Club home page Giter Club logo

kubectl-images's Introduction

kubectl-images

πŸ•Έ Show container images used in the cluster.

kubectl-images makes use of the kubectl command. It first calls kubectl get pods to retrieve pods details and filters out the container image information of each pod, then prints out the final result in a table/json/yaml view.

πŸ”° Installation

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
/

Build from source code

$ 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

Download the binary

# Refer to the link: https://github.com/chenjiandongx/kubectl-images/releases
# Download the binary and then...
$ chmod +x kubectl-images && mv kubectl-images /usr/local/bin/
$ kubectl images --help

πŸ“ Usage

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

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

Examples:
  # display a table of all images in current namespace using podName/containerName/containerImage as columns.
  kubectl images

  # display images info in yaml format
  kubectl images -oy

  # display a table of images that match 'nginx' podname regex in 'dev' namespace using podName/containerImage as columns.
  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, 4:ImagePullPolicy] (default "1,2,3")
  -C, --context string         The name of the kubeconfig context to use.
  -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.
  -o, --output-format string   output format. [json(j)|table(t)|yaml(y)] (default "table")
  -u, --unique                 Unique images group by namespace/container/images/pullPolicy.
      --version                version for kubectl-images

πŸ”– Glances

~ 🐢 kubectl images -n kube-system -oy dns
- pod: coredns-78fcd69978-9pbjh
  container: coredns
  image: kube-system
- pod: coredns-78fcd69978-jh7m2
  container: coredns
  image: kube-system

~ 🐢 kubectl images -A -c 0,1,3
[Summary]: 2 namespaces, 11 pods, 11 containers and 9 different images
+-------------+----------------------------------------+--------------------------------------------+
|  Namespace  |                  Pod                   |                   Image                    |
+-------------+----------------------------------------+--------------------------------------------+
| kube-system | coredns-78fcd69978-9pbjh               | k8s.gcr.io/coredns/coredns:v1.8.4          |
+             +----------------------------------------+                                            +
|             | coredns-78fcd69978-jh7m2               |                                            |
+             +----------------------------------------+--------------------------------------------+
|             | etcd-docker-desktop                    | k8s.gcr.io/etcd:3.5.0-0                    |
+             +----------------------------------------+--------------------------------------------+
|             | kube-apiserver-docker-desktop          | k8s.gcr.io/kube-apiserver:v1.22.5          |
+             +----------------------------------------+--------------------------------------------+
|             | kube-controller-manager-docker-desktop | k8s.gcr.io/kube-controller-manager:v1.22.5 |
+             +----------------------------------------+--------------------------------------------+
|             | kube-proxy-vc7fv                       | k8s.gcr.io/kube-proxy:v1.22.5              |
+             +----------------------------------------+--------------------------------------------+
|             | kube-scheduler-docker-desktop          | k8s.gcr.io/kube-scheduler:v1.22.5          |
+             +----------------------------------------+--------------------------------------------+
|             | storage-provisioner                    | docker/desktop-storage-provisioner:v2.0    |
+             +----------------------------------------+--------------------------------------------+
|             | vpnkit-controller                      | docker/desktop-vpnkit-controller:v2.0      |
+-------------+----------------------------------------+--------------------------------------------+
| nginx       | nginx-deployment-66b6c48dd5-s9wv5      | nginx:1.14.2                               |
+             +----------------------------------------+                                            +
|             | nginx-deployment-66b6c48dd5-wmn9x      |                                            |
+-------------+----------------------------------------+--------------------------------------------+

~ 🐢 kubectl images -A -c 0,1,3 -u
[Summary]: 2 namespaces, 11 pods, 11 containers and 9 different images
+-------------+----------------------------------------+--------------------------------------------+
|  Namespace  |                  Pod                   |                   Image                    |
+-------------+----------------------------------------+--------------------------------------------+
| kube-system | coredns-78fcd69978-9pbjh               | k8s.gcr.io/coredns/coredns:v1.8.4          |                                      +
+             +----------------------------------------+--------------------------------------------+
|             | etcd-docker-desktop                    | k8s.gcr.io/etcd:3.5.0-0                    |
+             +----------------------------------------+--------------------------------------------+
|             | kube-apiserver-docker-desktop          | k8s.gcr.io/kube-apiserver:v1.22.5          |
+             +----------------------------------------+--------------------------------------------+
|             | kube-controller-manager-docker-desktop | k8s.gcr.io/kube-controller-manager:v1.22.5 |
+             +----------------------------------------+--------------------------------------------+
|             | kube-proxy-vc7fv                       | k8s.gcr.io/kube-proxy:v1.22.5              |
+             +----------------------------------------+--------------------------------------------+
|             | kube-scheduler-docker-desktop          | k8s.gcr.io/kube-scheduler:v1.22.5          |
+             +----------------------------------------+--------------------------------------------+
|             | storage-provisioner                    | docker/desktop-storage-provisioner:v2.0    |
+             +----------------------------------------+--------------------------------------------+
|             | vpnkit-controller                      | docker/desktop-vpnkit-controller:v2.0      |
+-------------+----------------------------------------+--------------------------------------------+
| nginx       | nginx-deployment-66b6c48dd5-s9wv5      | nginx:1.14.2                               |
+-------------+----------------------------------------+--------------------------------------------+

~ 🐢 kubectl images -c 0,1,2,3,4 -n nginx -oj
[Summary]: 1 namespaces, 2 pods, 2 containers and 1 different images
[
 {
  "namespace": "nginx",
  "pod": "nginx-deployment-66b6c48dd5-s9wv5",
  "container": "nginx",
  "image": "nginx",
  "imagePullPolicy": "IfNotPresent"
 },
 {
  "namespace": "nginx",
  "pod": "nginx-deployment-66b6c48dd5-wmn9x",
  "container": "nginx",
  "image": "nginx",
  "imagePullPolicy": "IfNotPresent"
 }
]

πŸ“ƒ License

MIT Β©chenjiandongx

kubectl-images's People

Contributors

chenjiandongx avatar yuankunzhang avatar fleeto avatar ahmetb avatar superbrothers avatar luffyao avatar wutongjie23hao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.