Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active October 3, 2024 02:29
Show Gist options
  • Save zulhfreelancer/5446c3cc4fae527ed5f4af4f044e7557 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/5446c3cc4fae527ed5f4af4f044e7557 to your computer and use it in GitHub Desktop.
How to find a pod by UID?

How to find a pod by UID?

Option #1

kubectl get pods -A -o json | jq -r '.items[] | select(.metadata.uid == "<UID>") | .metadata.name, .metadata.namespace'

Option #2

kubectl get pods -A -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,UID:.metadata.uid | grep <UID>

Option #3

If you're using Docker, run this on each node

docker ps -a --format '{{.Names}}' | grep <UID>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment