Last active
May 5, 2020 17:28
-
-
Save ironcladlou/e709f63c5db8ffd5fed8a407509ea93d to your computer and use it in GitHub Desktop.
OpenShift Network Helpers
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 | |
set -euo pipefail | |
NAMESPACE=$1 | |
NAME=$2 | |
IMAGE="${IMAGE:-quay.io/dmace/ditm}" | |
NODE_NAME="$(oc get --namespace $NAMESPACE pods $NAME -o go-template='{{ .spec.nodeName }}')" | |
CONTAINER_ID_URI="$(oc get --namespace $NAMESPACE pods $NAME -o go-template='{{ (index .status.containerStatuses 0).containerID }}')" | |
CONTAINER_ID="${CONTAINER_ID_URI:8}" | |
oc debug --quiet --image $IMAGE nodes/$NODE_NAME --tty=true CONTAINER_ID=$CONTAINER_ID -- /bin/bash -c $'PID=$(chroot /host crictl inspect $CONTAINER_ID -o yaml | grep pid | awk \'{print $2}\'); echo PID=$PID;nsenter -t $PID --net tcpdump -U' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment