Skip to content

Instantly share code, notes, and snippets.

@ironcladlou
Last active May 5, 2020 17:28
Show Gist options
  • Save ironcladlou/e709f63c5db8ffd5fed8a407509ea93d to your computer and use it in GitHub Desktop.
Save ironcladlou/e709f63c5db8ffd5fed8a407509ea93d to your computer and use it in GitHub Desktop.
OpenShift Network Helpers
#!/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