Get docker image LABELS via Kubernetes API Get docker image LABELS via Kubernetes API kubernetes kubernetes

Get docker image LABELS via Kubernetes API


One option is to fetch the deployment yaml where you can view which docker image is used.

First, fetch deployments

kubectl get deployments

Then use the name of the deployment you want and fetch the config

kubectl get deployments your-deployment-name -o yaml --export


Well if you want to get the labels much more easier, you can just add a --show-labels when getting your pods:

kubectl get po --show-labelskubectl get deploy --show-labelskubectl get all --show-labels

you can also use the api only to list or watch or filter pods but unfortunately, labels need to be specified to do so you can see some examples as follow:

?labelSelector=environment%3Dproduction,tier%3Dfrontend?labelSelector=environment+in+%28production%2Cqa%29%2Ctier+in+%28frontend%29

This answer was 100% based from Kubernetes documentation, you can also check https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more info or more specefic usage, anyhow, do not hesitate to send me a message/mail/tag if future questions