Skip to content

Instantly share code, notes, and snippets.

@michael-erasmus
Last active May 22, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michael-erasmus/34f92ea204e3c08a0ff0acfc81c4255f to your computer and use it in GitHub Desktop.
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
#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