Home > Back-end >  How to retrieve a specific Kubernetes deployment image tag using java api?
How to retrieve a specific Kubernetes deployment image tag using java api?

Time:05-18

What I need is to retrieve image tag using java api for Kubernetes. basically, what the command kubectl -n <NAMESPACE> get deployments.apps <DEPLOYMENT> -o jsonpath={..image} does. Right now I am able to get a list of deployments I need that info from (V1DeploymentList) but I am not sure how to retrieve image tags from there.

CodePudding user response:

Anyway I have found where image tags are stored.

deployment.getSpec().getTemplate().getSpec().getContainers()

leads you to the list of containers List<V1Container> and each of those containers contains an image tag relevant for the deployment, you can retrieve them like this: container.getImage()

  • Related