Here’s a quick, handy one-liner that I whipped up the other day… if you want to find all the images presently running in your Kubernetes cluster this will give you a newline-delimited list:
kubectl get pods -o jsonpath="{.items[*].spec.containers[*].image}" | tr " " "\n" | sort -u
This is probably completely obvious to those with better bash-fu and ability to write Kubernetes YAML from memory than I, but hey, it took me a few minutes to come up with and I’d like to save my future self a history grep
and help those who were in the same boat as I was when I sought how to do this initially. I use a Mac at work so this is only tested with zsh and BSD utils, but since the heaviest part of the invocation happens in the kubectl
(Look Ma! No jq
!) and everything else is pretty standard there shouldn’t be any portability issues.