1,查看镜像

 kubectl -n xxx get pods | grep Running | awk '{print $1}' | xargs -r -I '{}' kubectl -n xxx get pods {} -o=jsonpath='{.status.containerStatuses[0].image}{"\n"}' | sort  

2,去重查看

kubectl -n namespace get pods -o jsonpath='{.items[*].spec.containers[*].image}' | tr ' ' '\n' | sort | uniq

3, 同时显示pod名称和镜像

kubectl get pods -n namespace -o=jsonpath='{range .items[*]}{"Pod: "}{.metadata.name}{"\n"}{"Container Images: "}{range .spec.containers[*]}{.image}{"\n"}{end}{"\n"}{end}'

4,查看所有deployment和其中的镜像

kubectl get deployments -n namespace -o=custom-columns=NAME:.metadata.name,IMAGE:.spec.template.spec.containers[*].image

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐