Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the image and SHA image ID of images in pod on Kubernetes deployment

Tags:

How can I get the image ID (the docker sha256 hash) of a image / container within a Kubernetes deployment?

like image 835
Chris Stryczynski Avatar asked Aug 10 '17 11:08

Chris Stryczynski


People also ask

How do you get PID of Kubernetes pod?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.


1 Answers

Something like this will do the trick (you must have jq installed):

$ kubectl get pod --namespace=xx yyyy -o json | jq '.status.containerStatuses[] | { "image": .image, "imageID": .imageID }'
{
  "image": "nginx:latest",
  "imageID": "docker://sha256:b8efb18f159bd948486f18bd8940b56fd2298b438229f5bd2bcf4cedcf037448"
}
{
  "image": "eu.gcr.io/zzzzzzz/php-fpm-5:latest",
  "imageID": "docker://sha256:6ba3fe274b6110d7310f164eaaaaaaaaaa707a69df7324a1a0817fe3b475566a"
}
like image 174
Janos Lenart Avatar answered Sep 24 '22 20:09

Janos Lenart