Skip to content

Instantly share code, notes, and snippets.

@jeesmon
Created September 30, 2021 19:41
Show Gist options
  • Save jeesmon/5d791e97973b4afee967c63cccfe2441 to your computer and use it in GitHub Desktop.
Save jeesmon/5d791e97973b4afee967c63cccfe2441 to your computer and use it in GitHub Desktop.
Find ownerReferences of pods in OpenShift cluster
oc get po -A -o wide | grep {filter} | while read a b c;
do
r=$(echo -n $a $b; oc get po -n $a $b -o jsonpath='{range .metadata.ownerReferences[*]} {.kind} {.name}{"\n"}{end}');
echo $r;
if [[ $r == *"ReplicaSet"* ]];
then echo $r | while read a b c d;
do
oc get rs -n $a $d -o jsonpath='{range .metadata.ownerReferences[*]} {.kind} {.name}{"\n"}{end}';
done;
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment