How-To: Identify The Virtual Interface of a Pod in the Root Namespace Using Flannel as the Network B

Problem

Identify the virtual interface of a particular pod in the root namespace of the node using flannel as Network backend.

Environment

  • Platform9 Managed Kubernetes - All Versions

  • Flannel

Procedure

  1. Use the docker command to identify the pause container for the pod as it holds the network namespace for the pod.

# docker ps | grep -i busybox2 | grep pause

f15ae72287e0 k8s.gcr.io/pause:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_mybusybox2_default_2a12aac4-ed54-4c99-aa0e-be32f793f41d_0
  1. Run docker inspect on the container Id obtained from the above command and look for the SandboxKey to get the namespace created for the pod.

# docker inspect f15ae72287e0 | grep -i sandboxkey

"SandboxKey": "/var/run/docker/netns/5048a1a60e3b",
  1. Use nsenter to get the interface details within the pod namespace.

circle-info

Note

ip netns command can not be used for the docker namespaces as it only knows about namespaces listed in /var/run/netns/

  1. Run ethtool on the interface with the pod's IP in the namespace above to obtain the peer index of the Veth-pair for the interface

  1. List the network interface on the node (root namespace) using ip command, the interface listed at the index obtained in the above step ( 27 in this case ) is the virtual interface for the pod in the root namespace.

Last updated