How do I get the pod ID in Kubernetes?

Use kubectl jsonpath

To get a specific pod's UID:

$ kubectl get pods -n <namespace> <pod-name> -o jsonpath='{.metadata.uid}'
$ kubectl get pods -n kube-system kubedb-66f78 -o jsonpath='{.metadata.uid}'
275ecb36-5aa8-4c2a-9c47-d8bb681b9aff⏎

Use kubectl custom-columns

List all PodName along with its UID of a namespace:

$ kubectl get pods -n <namespace> -o custom-columns=PodName:.metadata.name,PodUID:.metadata.uid
$ kubectl get pods -n kube-system -o custom-columns=PodName:.metadata.name,PodUID:.metadata.uid
PodName                                      PodUID
coredns-6955765f44-8kp9t                     0ae5c03d-5fb3-4eb9-9de8-2bd4b51606ba
coredns-6955765f44-ccqgg                     6aaa09a1-241a-4013-b706-fe80ae371206
etcd-kind-control-plane                      c7304563-95a8-4428-881e-422ce3e073e7
kindnet-jgb95                                f906a249-ab9d-4180-9afa-4075e2058ac7
kube-apiserver-kind-control-plane            971165e8-6c2e-4f99-8368-7802c1e55e60
kube-controller-manager-kind-control-plane   a0dce3a7-a734-485d-bfee-8ac3de6bb486
kube-proxy-27wgd                             d900c0b2-dc21-46b5-a97e-f30e830aa9be
kube-scheduler-kind-control-plane            9c6f2399-4986-4259-9cd7-875eff1d7198

Use Unix/Linux command grep

You can use kubectl get pods along with grep.

$ kubectl get pods -n <namespace> <pod-name> -o yaml | grep uid
uid: bcfbdfb5-ce0f-11e9-b83e-080027d4916d

Optionally, you can try this:

$ kubectl get pod -n <namespace> <pod_name> -o jsonpath='{.metadata.uid}'