fish wrapper for simplyfying oc usage against pods
This file contains 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
function ocp | |
if test (count $argv) -gt 1 | |
set podname $argv[1] | |
set oc_cmd $argv[2] | |
set pods (oc get pods | grep -i running | grep $podname | awk '{print $1}') | |
if test (count $pods) -eq 0 | |
echo "=> Found no pods using filter: $podname" | |
oc project | |
oc get pods | |
end | |
if test (count $argv) -gt 2 | |
set rest $argv[3..-1] | |
end | |
echo "" | |
echo "=> Running $oc_cmd on pods: $pods(set_color normal)" | |
echo "" | |
for pod in $pods | |
echo "=> $oc_cmd $pod $rest" | |
oc $oc_cmd $pod $rest | |
echo "command exited with status: $status" | |
echo "" | |
end | |
else | |
echo "usage:" | |
echo "ocp <PODNAME> <OC_CMD> [ARGS]" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
ocp <PODNAME> <OC_CMD> [ARGS]
examples:
tail logs from a pod with name containing
frontend
:ocp frontend tail -f
given the following list of pods:
will tail logs of
frontend-10-4aamb