I'd like to get a CSV for our security team with all the container images running in our kubernetes cluster right now including the image digests and namespace. How can I do that?

1 Answer 1


This depends on anchore kai (which you just download and drop in your path. https://github.com/anchore/kai/releases) and jq which you probably already have installed. This also assumes your kubectl is configured and pointed to the cluster with needed credentials to read everything you need to acquire.

kai -i \
  |jq --raw-output '.results[] \
    | {"namespace": .namespace, "image": .images[].tag, "digest": .images[].repoDigest} \
    | [.namespace, .image, .digest] \
    | @csv' \

The first line is getting the images using kai. The -i outputs the inventory to the commandline. This is in a json format. Then I use jq to get the results in line 2. In line 3 I re-arrange the results so the namespace is associated with each image in the same array. Then I dump these into a bunch of individual rows in line 4 and finally in line 5 output that to stdout in a CSV format instead of json.

You'll get a count of the images per namespace to stderr and the csv to stdout so you can simply add > inventory.csv to the end of the command to save it off to a file. You'll still see the stderr output to the screen so you can follow along.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.