Last active
May 22, 2017 21:27
-
-
Save michael-erasmus/34f92ea204e3c08a0ff0acfc81c4255f to your computer and use it in GitHub Desktop.
Copies the name of the first k8s container matching a service name into the clipboard
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
#Copies the name of the first k8s container matching a service name into the clipboard | |
#Requires jq and pbcopy (made for Mac OSX) | |
function po_name { | |
if [ -z "$1" ] | |
then | |
echo "Please specify the service name" | |
else | |
pattern=${1-$DEFAULT} | |
kubectl get po --output=json | jq -r '.items | .[] | .metadata.name' | grep $pattern | head -n 1 | tr -d '\n'| pbcopy | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment