Created
August 16, 2022 11:10
-
-
Save patrickshan/e431dc2ef90ed1e8a4d15029a341a908 to your computer and use it in GitHub Desktop.
Find and print out namespace and pod name for all naked pods in a Kubernete cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get pods -A -ojson | jq -c '.items[] | select(.metadata.ownerReferences == null) | "\(.metadata.namespace) => \(.metadata.name)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
backup all the naked pods specs after filtering out some fields:
kubectl get pods -A -oyaml | yq '.items[] | select(.metadata | has("ownerReferences") | not) | split_doc' | yq 'del(.status, .metadata.uid, .metadata.resourceVersion, .metadata.creationTimestamp, .metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")'