kubernetes: ContainerStatus imageID is inconsistent / badly documented

What happened?

the imageID property on ContainerStatus seems inconsistent on clusters running different CRI implementations (or the same CRI implementation with different configuration), which makes it impossible to actually tell which container image is being used.

On GKE, imageID is a repo digest, though often to a “fat manifest”, so to figure out which container is actually used you have to check the node architecture.

  - containerID: containerd://6eed9a2af53b5a56f39328fe1349395e56a0d01b443780a5d3ded56c3690a7e5
    image: gke.gcr.io/k8s-dns-kube-dns:1.22.12-gke.0
    imageID: gke.gcr.io/k8s-dns-kube-dns@sha256:b18b51683f6633979434a24ca2341e3b6bab8af0167b1be6b43f901aa615b38e

On Kind, it seems to actually be an Image ID from the image configuration object, so it is not possible to resolve on a container registry beyond hoping the image property isn’t pointing to a moving target and then matching the image ID of the resolved image.

  - containerID: containerd://058f852ac99502198092865c214c548c871f20e1ac5d9c9e75b2f4ae4ed9622c
    image: registry.k8s.io/coredns/coredns:v1.9.3
    imageID: sha256:b19406328e70dd2f6a36d6dbe4e867b0684ced2fdeb2f02ecb54ead39ec0bac0
$ docker image inspect registry.k8s.io/coredns/coredns:v1.9.3 | jq .[0].Id
"sha256:b19406328e70dd2f6a36d6dbe4e867b0684ced2fdeb2f02ecb54ead39ec0bac0"

The field is simply documented as “ImageID of the container’s image.”. This is insufficient and should be changed if the content of the field being implementation dependent is intentional.

What did you expect to happen?

imageID has predictable behavior and ideally can be used to identify the exact image used (repo digest or single-arch manifest digest)

How can we reproduce it (as minimally and precisely as possible)?

kind create cluster

get any pod

pull the same image, compare imageID provided with config and manifests

Anything else we need to know?

No response

Kubernetes version

CRI issue.

Cloud provider

Several.

OS version

No response

Install tools

No response

Container runtime (CRI) and version (if applicable)

Several.

Related plugins (CNI, CSI, …) and versions (if applicable)

No response

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 9
  • Comments: 23 (14 by maintainers)

Most upvoted comments

(I’m the ghost OP)

Our original issue was a bit more multi-layered. We wanted to do scans of all images deployed with syft to build an inventory, but didn’t control many pipelines across the company. Our aim was to find all images in use on clusters, fetch them and scan them after the fact.

So it’s important to be able to resolve the correct container image ID and architecture and (possibly manifest list) distribution manifest. I’d suggest providing the container image ID and the resolved (with sha256 tag) manifest, and then possibly the architecture for good measure (though this can be derived from the node architecture or by iterating through images and comparing IDs)

What about adding a new key, e.g. imageDigest? This will ensure that existing functionality will not break.

/reopen /help /remove-lifecycle rotten @030 would you like to work on this?

Even if we change the behaviour here, it’s good to document the current behavior and get that detail merged first. That way, it’s on record for older docs versions.