We are building our docker-images, and adding a few metadata-labels during docker build, e.g:
docker build --label no.company.version=1.2.3 .
When we at some point later in time use this image in a kubernetes pod, we would like to retreive that labels from the kubernetes api. This would be useful for tracking other metadata than what is encoded in the image tag itself.
The labels are available through docker on the node, but I can not find any way to retreive them in kubernetes. Is this possible?
To check the labels of a particular Image, you can use the Docker Inspect command. Start the Docker Container. Execute the Inspect Command. Inside the LABELS object, you can find all the labels associated with the image that you have specified inside your Dockerfile.
If using Openshift, the docker labels are visible on the ImageStreamTag object (apiVersion: image.openshift.io/v1) if you happen to be using that feature.
oc get istag myimage:latest -o yaml
apiVersion: image.openshift.io.v1
generation: 2
image:
dockerImageLayers:
- mediaType: application/vnd.docker.image.rootfs.diff.tar.gzip
name: sha256:690b26398d8aadd19a2936c1b51a335c06e0887775135f3186bc318c2dbf6d15
size: 31494540
- ...etc...
dockerImageManifestMediaType: application/vnd.docker.distribution.manifest.v2+json
dockerImageMetadata:
Architecture: amd64
Config:
Image: sha256:5593b121415d0e9e23ae1041628869379937580fd29d4e90d163f2101bd4d96d
Labels:
architecture: x86_64
mvn.version: 1.0.0-SNAPSHOT
git.branch: master
git.revision: 17c5424fcf578b13144e03d638becfb86e18ff92
... etc...
querying docker metadata from kubernetes api is not supported for now. there is a PR opened to accommodate this request. please follow
https://github.com/kubernetes/kubernetes/issues/47368
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With