[英]How to check programmatically for the existence of a docker image before calling create_namespaced_pod() of kubernetes
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.我正在使用kubernetes-client
package 的create_namespaced_pod()
从注册表中的 docker 图像动态创建 kubernetes pod。
How do I check if the Docker image exists in the registry before calling create_namespaced_pod()
?在调用create_namespaced_pod()
之前,如何检查注册表中是否存在 Docker 映像? I want to avoid creating the pod and then having to deal with error messages.我想避免创建 pod 然后不得不处理错误消息。
you may use docker registry ls
to list the contents of your registry and parse for your image specifically.您可以使用docker registry ls
列出注册表的内容并专门解析您的图像。 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.如果ls
不适合您,您可以尝试在注册表中对映像的 URL 进行简单的 HTTP 调用,然后检查响应代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.