k8s查看当前命名空间下所有运行的 pod 对应的镜像

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

你可能感兴趣的:(k8s,kubernetes,linux,k8s)