Last active
May 17, 2018 14:22
-
-
Save guilhem/c3c1896b1947b827a65e31a785efc056 to your computer and use it in GitHub Desktop.
kubectl plugin to ssh on internalIP of a node
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
#!/bin/bash | |
NODE=${1} | |
USER=${KUBECTL_PLUGINS_LOCAL_FLAG_USER} | |
IP=$($KUBECTL_PLUGINS_CALLER get nodes "$NODE" -o=jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}') | |
CONNECTION="$IP" | |
if [[ -n $USER ]] | |
then | |
CONNECTION=$USER@$CONNECTION | |
fi | |
ssh "$CONNECTION" |
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
name: "ssh" | |
shortDesc: "ssh to nodes" | |
longDesc: "" | |
example: "kubectl ssh my-node" | |
command: "./node-ssh" | |
flags: | |
- name: "user" | |
shorthand: "u" | |
desc: "Username for ssh connection" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment