Reputation: 45340
How can I get a particular Kubernetes annotation from a deployment resource using kubectl
? I know I can dynamically set an annotation on a deployment using:
kubectl annotate deployment api imageTag=dev-ac5ba48.k1dp9
Is there a single kubectl
command to then read this deployments imageTag
annotation?
Upvotes: 1
Views: 2872
Reputation: 2713
You can use jsonpath for that:
kubectl get deployment api -o=jsonpath='{.metadata.annotations}'
The command above will give you all the annotations of your deployment api.
For reference you can take a look at this doc page as it may help.
Upvotes: 1
Reputation: 1430
You can use the following command to get the imageTag
annotation (given that annotation exists):
kubectl get deploy DEPLOY_NAME -o jsonpath='{.metadata.annotations.imageTag}'
Upvotes: 2