Skip to content

Examples

Tomofumi Hayashi edited this page May 4, 2017 · 10 revisions

Examples

koko runs at container hosts (not inside container), create interface (vxlan or veth) and put it in container namespace. koko supports following scenarios.

Inside one container host (with veth)

Docker <-> Docker

connect between docker containers with veth

Commands

# Config veth for Docker containers
./koko -d <container>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]] \
       -d <container>,<linkname>[,[<ip4addr>/<prefixlen>][,<ip6addr>/<prefixlen>]]

<container>: Docker's container identifier (CONTAINER ID or name)
<linkname>: veth link name
(optional) <ip4addr>/<prefixlen>: IPv4 address with netmask (e.g. 192.0.0.1/24)
(optional) <ip6addr>/<prefixlen>: IPv6 address with netmask (e.g. 2001:DB8::1/64)

netns <-> netns

connect between netns containers with veth

Commands

# Config veth for netns
./koko -n <netns name>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]] \
       -n <netns name>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]]

<netns name>: netns name that is given by 'ip netns' command
<linkname>: veth link name
(optional) <ip4addr>/<prefixlen>: IPv4 address with netmask (e.g. 192.0.0.1/24)
(optional) <ip6addr>/<prefixlen>: IPv6 address with netmask (e.g. 2001:DB8::1/64)

Docker <-> netns

connect between docker container and netns container with veth

Commands

# Config veth for Docker containers
./koko -d <container>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]] \
       -n <netns name>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]]

<container>: Docker's container identifier (CONTAINER ID or name)
<linkname>: veth link name
<netns name>: netns name that is given by 'ip netns' command
(optional) <ip4addr>/<prefixlen>: IPv4 address with netmask (e.g. 192.0.0.1/24)
(optional) <ip6addr>/<prefixlen>: IPv6 address with netmask (e.g. 2001:DB8::1/64)

Across container hosts (with vxlan)

Docker <-> vxlan

connect between docker containers with vxlan

Commands

Following commands must be executed both container hosts to connect between two containers.

# Config vxlan for Docker container
./koko -d <container>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]] \
       -x <parent IF>,<remote IP>,<vxlan id>

<container>: Docker's container identifier (CONTAINER ID or name)
<linkname>: veth link name
(optional) <ip4addr>/<prefixlen>: IPv4 address with netmask (e.g. 192.0.0.1/24)
(optional) <ip6addr>/<prefixlen>: IPv6 address with netmask (e.g. 2001:DB8::1/64)
<parent IF>: Egress IF name for vxlan (e.g. eth0)
<remote IP>: Unicast destination IP address for endpoint
<vxlan id>: vxlan id

netns <-> vxlan

connect between netns containers with vxlan

Commands

Following commands must be executed both container hosts to connect between two containers.

# Config vxlan with IPv4 addr for netns
./koko -n <netns name>,<linkname>[,[<ip4addr>/<prefixlen>>][,<ip6addr>/<prefixlen>]] \
       -x <parent IF>,<remote IP>,<vxlan id>

<netns name>: netns name that is given by 'ip netns' command
<linkname>: veth link name
(optional) <ip4addr>/<prefixlen>: IPv4 address with netmask (e.g. 192.0.0.1/24)
(optional) <ip6addr>/<prefixlen>: IPv6 address with netmask (e.g. 2001:DB8::1/64)
<parent IF>: Egress IF name for vxlan (e.g. eth0)
<remote IP>: Unicast destination IP address for endpoint
<vxlan id>: vxlan id

Docker <-> netns

connect between docker container and netns container with vxlan

Commands

For each container hosts, execute koko with above (Docker<->vxlan and netns<->vxlan)

Clone this wiki locally