Fetching Docker image information using python SDK

10/7/2018

I am currently using Kubernetes Python SDK to fetch relevant information from my k8s cluster. I am running this from outside the cluster.

I have a requirement of fetching the images of all the POD's running within a namespace. I did look at Docker python SDK but that requires me to be running the script on the cluster itself which i want to avoid.

Is there a way to get this done ?

TIA

-- Rakshith Venkatesh
docker
kubernetes

1 Answer

10/7/2018

that requires me to be running the script on the cluster itself

No, it should not: the kubernetes-client python performs operations similar to kubectl calls (as detailed here).
And kubectl calls can be done from any client with a properly set .kube/config file.

Once you get the image name from a kubectl describe po/mypod, you might need to docker pull that image locally if you want more (like a docker history).

The OP Raks adds in the comments:

I wanted to know if there is a python client API that actually gives me an option to do docker pull/save/load of an image as such

The docker-py library can pull/load/save images.

-- VonC
Source: StackOverflow