Openvswitch implement Docker container spanning host interconnect

Source: Internet
Author: User
Tags openvswitch

1. Openvswitch Introduction

The Open VSwitch (hereinafter referred to as OVS) is a virtual switch run on a virtualized platform (such as Kvm,xen), which is led by Nicira Networks. On the virtualization platform, OvS can provide 2-layer switching function for dynamically changing endpoints, and it is very good to control access policies, network isolation, traffic monitoring and so on in the virtual network. The main implementation code is portable C code.

It is designed to allow large-scale network automation to be extended programmatically, while still supporting standard management interfaces and protocols such as NETFLOW,SFLOW,SPAN,RSPAN,CLI,LACP,802.1AG. In addition, it is designed to support distributed environments spanning multiple physical servers, similar to VMware's vmnetwork distributed switch or Cisconexus 1000v. Open Vswitch supports a variety of Linux virtualization protocols, including Xen/xen SERVER,KVM, and VirtualBox.

2. Implement the container inter-host communication by Vxlan Way

This test, through Openvswitch's Vxlan network, enables two physical host containers to exchange visits across hosts.

2.1 Topology Diagram

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7A/C5/wKiom1a0UMGTMqwEAACeUX6KmvI583.png "title=" 001. PNG "alt=" Wkiom1a0umgtmqweaaceux6kmvi583.png "/>

2.2 Configuring OvS

(1) The openvswitch portion of the host10 and host11 two hosts is configured here through two scripts. As follows:

#host10 [[Email protected] ~]# cat vsctl-add.sh#!/bin/bashovs-vsctl add-br br0    #新建两个虚拟交换机ovs-vsctl add-br br1ifconfig eth0 0 up    # Assigning the physical host IP to br1ifconfig br1 192.168.1.10/24 uproute add default gw  192.168.1.1ovs-vsctl add-port br1 eth0   #将eth0加入br1ovs-vsctl add-port br0  docker0   #将docker0加入br0ifconfig  br0 172.17.0.2/24 up  # Configuring the ipifconfig docker0 172.17.0.1/24 up#host11[[email protected] ~]#  of Br0 and Docker0 cat vsctl-add.sh#!/bin/bashovs-vsctl add-br br0  ovs-vsctl add-br  Br1ifconfig eth0 0 upifconfig br1 192.168.1.11/24 uproute add default  gw 192.168.1.1ovs-vsctl add-port br1 eth0ovs-vsctl add-port br0  Docker0ifconfig br0 172.17.0.4/24 upifcoNfig docker0 172.17.0.3/24 up Tip: The above two scripts are executed via SSH on a physical host through  nohup ./vsctl-add.sh  &  execution, or there will be a failure of network failure to perform successfully.

         (2) configuring Vxlan for cross-host interconnection

#host10ovs-vsctl add-port br0 vx1 -- set interface vx1 type=vxlan  options:remote_ip=192.168.1.11#host11ovs-vsctl add-port br0 vx1 -- set  interface vx1 type=vxlan options:remote_ip=192.168.1.10# after execution, see [[email protected] ~]#  ovs-vsctl showa8251e22-bb31-4ee6-8321-49fbd0f1b735    Bridge  "Br0"          Port  "VX1"              Interface  "VX1"                  type: vxlan                 options: {remote_ip= "192.168.1.11"}         Port  "veth1pl5407"              Interface  "veth1pl5407" &Nbsp;       port  "Br0"              Interface  "Br0"                  type: internal        Port  " Docker0 "            Interface " Docker0 "         Port  "veth1pl4977"              Interface  "veth1pl4977"     Bridge  "BR1"          Port  "Eth0"              Interface  "eth0"         Port  "BR1"             Interface  "BR1"         &nbSp;        type: internal 

2.3 Creation of four containers

Here through the pipework fixed the container IP address, later added to the/etc/rc.local inside realizes the boot automatic configuration.

#host10docker run-itd--net=none--name test1 centos:6/bin/bashdocker run-itd--net=none--name test2 centos:6/bin/bas Hpipework br0 test1 172.17.0.101/[email protected]pipework br0 test2 172.17.0.102/[email protected] #host11docker run-  ITD--net=none--name test3 centos:6/bin/bashdocker run-itd--net=none--name test4 centos:6/bin/bashpipework br0 test3 172.17.0.103/[email protected]pipework br0 test4 172.17.0.104/[email protected]

2.4 Testing

Access to three additional containers from the Test1 container can communicate normally.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7A/C5/wKiom1a0WNGyPuTwAABYzUnlqr4810.png "title=" 002. PNG "alt=" Wkiom1a0wngyputwaabyzunlqr4810.png "/>


3. Summary

With this configuration, you can see the power of Openvswitch, OvS not only for Docker containers, but also for virtual hosting networks. The network configuration is greatly simplified through software-defined networks. Docker joins the overlay network after the 1.9 release, using OvS technology.

This article is from the "Orangebrain" blog, make sure to keep this source http://orangebrain.blog.51cto.com/11178429/1741242

Openvswitch implement Docker container spanning host interconnect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.