Skip to content

Instantly share code, notes, and snippets.

@chendotjs
Created January 6, 2020 09:24
Show Gist options
  • Save chendotjs/e51bb5cf47937165cc55788347dfc73c to your computer and use it in GitHub Desktop.
Save chendotjs/e51bb5cf47937165cc55788347dfc73c to your computer and use it in GitHub Desktop.
function e() {
set -eu
ns=${2-"default"}
pod=`kubectl -n $ns describe pod $1 | grep -A10 "^Containers:" | grep -Eo 'docker://.*$' | head -n 1 | sed 's/docker:\/\/\(.*\)$/\1/'`
pid=`docker inspect -f {{.State.Pid}} $pod`
echo "entering pod netns for $ns/$1"
cmd="nsenter -n --target $pid"
echo $cmd
$cmd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment