Main Menu

Search

Monday, July 29, 2024

KUBERNETES: Kubectl Command To View All Pods And List Containers & Images Part Of the All Pods (How To)


Below command can be used on Control node. In below command, we are listing pods part of all namespaces, you can change the command and list pods/container/images for the namespace you want using -n flag.

kubectl get pods --all-namespaces -o jsonpath='{range .items[*]}{"pod: "}{.metadata.name}{"\n"}{range .status.containerStatuses[*]}{"\tname: "}{.containerID}{"\n\timage: "}{.image}{"\n"}{end}'

Below is sameple output.

pod: details-v1-cf74bb974-8jfx5
name: cri-o://5630266da8cc049448888d722ea52859cb5fe0bbf9053222db9440ab889173c6
image: docker.io/istio/examples-bookinfo-details-v1:1.19.1
pod: productpage-v1-87d54dd59-2xqm2
name: cri-o://b8a374635c35e6725f9dceac159acf8ea65aba481fcb6d9fb9ef5c3f3182a635
image: docker.io/istio/examples-bookinfo-productpage-v1:1.19.1
pod: ratings-v1-7c4bbf97db-hcxgt
name: cri-o://5d32cd9f25e0f6189c903ff840239bc7b5459427cf861c0c40df3ddfd9041fb4
image: docker.io/istio/examples-bookinfo-ratings-v1:1.19.1

No comments:

Post a Comment