Last active
May 28, 2019 15:44
-
-
Save mgoodness/9e1c90d7b8fe14f04422bd0f44da9aed to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
while getopts ":u:" opt; do | |
case "$opt" in | |
u) | |
username="${OPTARG}" | |
;; | |
\?) | |
echo "Invalid option: -${OPTARG}" >&2 | |
return 1 | |
;; | |
:) | |
echo "Option -${OPTARG} requires an argument." >&2 | |
return 1 | |
;; | |
esac | |
done | |
shift "$((OPTIND-1))" | |
if [[ -z $1 ]]; then | |
echo "Node name required." >&2 | |
return 1 | |
else | |
ip="$(kubectl get nodes $1 -o go-template='{{range .status.addresses}}{{if eq .type "InternalIP"}}{{print .address}}{{end}}{{end}}')" | |
ssh "${username}@$ip" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment