Skip to content

Instantly share code, notes, and snippets.

@guilhem
Last active May 17, 2018 14:22
Show Gist options
  • Save guilhem/c3c1896b1947b827a65e31a785efc056 to your computer and use it in GitHub Desktop.
Save guilhem/c3c1896b1947b827a65e31a785efc056 to your computer and use it in GitHub Desktop.
kubectl plugin to ssh on internalIP of a node
#!/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"
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