Skip to content

Instantly share code, notes, and snippets.

@johscheuer
johscheuer / get_pod_netns.sh
Last active July 4, 2024 17:11
This script get's the netns from a Kubernetes pod
#### WAY with crictl
#### TODO validate crictl with docker runtime !!
# Get all pods of a specific node
#kubectl get po --field-selector=spec.nodeName="fluffy-master" --all-namespaces
kubectl get --all-namespaces po --field-selector=spec.nodeName=="$(hostname)" -o json | jq -r '.items[] | select(.status.hostIP!=.status.podIP) | "\(.metadata.name) \(.metadata.namespace)"'
# Get the Pod ID of the Pod with crictl
POD_ID=$(sudo crictl pods --name=nginx-6f858d4d45-vnszm --namespace=default -q --no-trunc)