Skip to content

Instantly share code, notes, and snippets.

@ronald
Last active September 11, 2018 10:15
Show Gist options
  • Save ronald/2cb469ea3fd225217ce8ab2916de7351 to your computer and use it in GitHub Desktop.
Save ronald/2cb469ea3fd225217ce8ab2916de7351 to your computer and use it in GitHub Desktop.
sshpod - shell function to access kubernetes pod
# add to .bashrc or .bash_profile
# usage:
# sshpod <podlabel>
# sshpod <podlabel> --namespace=<namespace>
sshpod() {
POD_NAME=$(kubectl get pods --selector "app=$1" -o jsonpath="{.items[0].metadata.name}" $2)
kubectl exec -it $POD_NAME /bin/bash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment