Skip to content

Instantly share code, notes, and snippets.

@jeesmon
Created January 18, 2022 14:30
Show Gist options
  • Save jeesmon/653e77a6b8c2fb9157699828c51f0ec4 to your computer and use it in GitHub Desktop.
Save jeesmon/653e77a6b8c2fb9157699828c51f0ec4 to your computer and use it in GitHub Desktop.
Find all resources owned by a CRD Kind
kubectl api-resources --no-headers | \
awk '{print $1}' | \
xargs -I '{}' kubectl get '{}' --all-namespaces -o json 2>/dev/null | \
jq '.items[] | \
select((.metadata.ownerReferences // [])[] | \
select(.kind == "YourCRD"))'

Credits: Oleg Matskiv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment