Each Kubernetes deployment gets this annotation:
$ kubectl describe deployment/myapp
Name:                   myapp
Namespace:              default
CreationTimestamp:      Sat, 24 Mar 2018 23:27:42 +0100
Labels:                 app=myapp
Annotations:            deployment.kubernetes.io/revision=5Is there a way to read that annotation (deployment.kubernetes.io/revision) from a pod that belongs to the deployment?
I tried Downward API, but that only allows to get annotations of the pod itself (not of its deployment).
Yes you can get the annotation from a pod using below command:
kubectl describe pod your_podnameand you will find Annotations section with all annotation for pod.
It has been a long time but here is what I do to get a specific annotation :
kubectl get ing test -o jsonpath='{.metadata.annotations.kubernetes\.io/ingress\.class}'So for you it would be :
kubectl get deploy myapp -o jsonpath='{.metadata.annotations.deployment\.kubernetes\.io/revision}'I hope it helps.
kubectl get pod POD_NAME -o jsonpath='{.metadata.annotations}'to get only the annotations section of the pod you can use
kubectl describe pod YOUR_POD_NAME | get -i 'annotations'you can also use jsonPath like
kubectl describe pod YOUR_POD_NAME -o jsonpath='{.metadata.annotations}{"\n"}'