Contents

Kubernetes Container Networking Interface

Network Namespaces

CNI(Container Network Interface) in CRI(Container Runtime Interface)

BRIDGE

Command

1
2
3
4
5
# Structure
bridge add <cid> <namespace>

# Example
bridge add 2e34dcf34 /var/run/netns/2e34dcf34

Bridge Process

CRI(Container Runtime Interface) Products Process

CNM(Container Network Model) for Docker

Docker
CNM is CNI of docker.
CNM is different with others CNI.

Models

Docker Network

1
2
3
4
5
# There's no network type 'cni-bridge' in docker
#docker run --network=cni-bridge nginx

# RUN
docker run --network=none nginx

Bridge

1
bridge add 2e34dcf34 /var/run/netns/2e34dcf34

CNI(Container Network Interface) Products

CNI in Kubernetes

CNI Config in kubelet

OptionDescriptionDefaultExample
–network-pluginPlugincnicni
–cni-conf-dirPlugin config directory/etc/cni/net.d/etc/cni/net.d
–cni-bin-dirPlugin binary directory/opt/cni/bin/opt/cni/bin

Check Running CNI Configuration

1
ps -aux | grep kubelet

Check CNI Plugins

1
2
3
4
ls <--cni-bin-dir>

# Example
ls /opt/cni/bin
1
2
bridge dhcp flannel host-local ipvlan loopback macvlan portmap ptp sample tuning
vlan weave-ipam weave-net weave-plugin-2.2.1

Check CNI Config Files

1
2
3
4
5
# Structure
ls <--cni-conf-dir>

# Example
ls /etc/cni/net.d
1
2
# Structure
10-bridge.conf

Check Config File

1
cat /etc/cni/net.d/10-bridge.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
  "cniVersion": "0.2.0",
  "name": "mynet",
  "type": "bridge",
  "bridge": "cni0",
  "isGateway": true,
  "ipMasq": true,
  "ipam": {
    "type": "host-local",
    "subnet": "10.22.0.0/16",
    "routes": [
      {
        "dst": "0.0.0.0/0"
      }
    ]
  }
}