How to check programmatically for the existence of a docker image before calling create_namespaced_pod() of kubernetes

4/16/2021

I am using create_namespaced_pod() of the kubernetes-client package to dynamically create kubernetes pods from docker images that are in an images registry.

How do I check if the Docker image exists in the registry before calling create_namespaced_pod()? I want to avoid creating the pod and then having to deal with error messages.

-- Ouss
docker
kubernetes
python
python-3.x

1 Answer

4/16/2021

you may use docker registry ls to list the contents of your registry and parse for your image specifically. if ls isn't working for you, you can try a simple HTTP call to the image's URL in the registry, and check the response code.

-- Noam Hacker
Source: StackOverflow