Code Monkey home page Code Monkey logo

docker-ovs-plugin's Introduction

docker-ovs-plugin

QuickStart Instructions

The quickstart instructions describe how to start the plugin in nat mode. Flat mode is described in the flat mode section.

1. Make sure you are using Docker 1.9 or later

2. You need to modprobe openvswitch on the machine where the Docker Daemon is located

$ docker-machine ssh default "sudo modprobe openvswitch"

3. Create the following docker-compose.yml file

plugin:
  image: gophernet/ovs-plugin
  volumes:
    - /run/docker/plugins:/run/docker/plugins
    - /var/run/docker.sock:/var/run/docker.sock
  net: host
  stdin_open: true
  tty: true
  privileged: true
  command: -d

ovs:
  image: socketplane/openvswitch:2.3.2
  cap_add:
    - NET_ADMIN
  net: host

4. docker-compose up -d

5. Now you are ready to create a new network

$ docker network create -d ovs mynet

6. Test it out!

$ docker run -itd --net=mynet --name=web nginx

$ docker run -it --rm --net=mynet busybox wget -qO- http://web

Flat Mode

There are two generic modes, flat and nat. The default mode is nat since it does not require any orchestration with the network because the address space is hidden behind iptables masquerading.

  • flat is simply an OVS bridge with the container link attached to it. An example would be a Docker host is plugged into a data center port that has a subnet of 192.168.1.0/24. You would start the plugin like so:
$ docker-ovs-plugin --gateway=192.168.1.1 --bridge-subnet=192.168.1.0/24 -mode=flat

You can also add these flags to the command section of your docker-compose.yml

  • Containers now start attached to an OVS bridge. It could be tagged or untagged but either way it is isolated and unable to communicate to anything outside of its bridge domain. In this case, you either add VXLAN tunnels to other bridges of the same bridge domain or add an eth interface to the bridge to allow access to the underlying network when traffic leaves the Docker host. To do so, you simply add the eth interface to the ovs bridge. Neither the bridge nor the eth interface need to have an IP address since traffic from the container is strictly L2. Warning if you are remoted into the physical host make sure you are not using an ethernet interface to attach to the bridge that is also your management interface since the eth interface no longer uses the IP address it had. The IP would need to be migrated to ovsbr-docker0 in this case. Allowing underlying network access to an OVS bridge can be done like so:
ovs-vsctl add-port ovsbr-docker0 eth2

Add an address to ovsbr-docker0 if you want an L3 interface on the L2 domain for the Docker host if you would like one for troubleshooting etc but it isn't required since flat mode cares only about MAC addresses and VLAN IDs like any other L2 domain would.

  • Example of OVS with an ethernet interface bound to it for external access to the container sitting on the same bridge. NAT mode doesn't need the eth interface because IPTables is doing NAT/PAAT instead of bridging all the way through.
$ ovs-vsctl show
e0de2079-66f0-4279-a1c8-46ba0672426e
    Manager "ptcp:6640"
        is_connected: true
    Bridge "ovsbr-docker0"
        Port "ovsbr-docker0"
            Interface "ovsbr-docker0"
                type: internal
        Port "ovs-veth0-d33a9"
            Interface "ovs-veth0-d33a9"
        Port "eth2"
            Interface "eth2"
    ovs_version: "2.3.1"

Flat Mode Note: Hosts will only be able to ping one another unless you add an ethernet interface to the docker-ovsbr0 bridge with something like ovs-vsctl add-port <bridge_name> <port_name>. NAT mode will masquerade around that issue. It is an inherent hastle of bridges that is unavoidable. This is a reason bridgeless implementation gopher-net/ipvlan-docker-plugin and gopher-net/macvlan-docker-plugin can be attractive.

Additional Notes:

  • The argument passed to --default-network the plugin is identified via ovs. More specifically, the socket file that currently defaults to /run/docker/plugins/ovs.sock.
  • The default bridge name in the example is ovsbr-docker0.
  • The bridge name is temporarily hardcoded. That and more will be configurable via flags. (Help us define and code those flags).
  • Add other flags as desired such as --dns=8.8.8.8 for DNS etc.
  • To view the Open vSwitch configuration, use ovs-vsctl show.
  • To view the OVSDB tables, run ovsdb-client dump. All of the mentioned OVS utils are part of the standard binary installations with very well documented man pages.
  • The containers are brought up on a flat bridge. This means there is no NATing occurring. A layer 2 adjacency such as a VLAN or overlay tunnel is required for multi-host communications. If the traffic needs to be routed an external process to act as a gateway (on the TODO list so dig in if interested in multi-host or overlays).
  • Download a quick video demo here.

Hacking and Contributing

Yes!! Please see issues for todos or add todos into issues! Only rule here is no jerks.

Since this plugin uses netlink for L3 IP assignments, a Linux host that can build vishvananda/netlink library is required.

  1. Install Go. OVS as listed above and a kernel >= 3.19.

  2. Install godeps by running go get github.com/tools/godep.

  3. Clone and start the OVS plugin:

    git clone https://github.com/gopher-net/docker-ovs-plugin.git
    cd docker-ovs-plugin/plugin
    # using godep restore will pull down the appropriate go dependencies
    godep restore
    go run main.go
    # or using explicit configuration flags:
    go run main.go -d --gateway=172.18.40.1 --bridge-subnet=172.18.40.0/24 -mode=nat
    
  4. The rest is the same as the Quickstart Section.

Note: If you are new to Go.

  • Go compile times are very fast due to linking being done statically. In order to link the libraries, Go looks for source code in the ~/go/src/ directory.
  • Typically you would clone the project to a directory like so go/src/github.com/gopher-net/docker-ovs-plugin/. Go knows where to look for the root of the go code, binaries and pkgs based on the $GOPATH shell ENV.
  • For example, you would clone to the path /home/<username>/go/src/github.com/gopher-net/docker-ovs-plugin/ and put export GOPATH=/home/<username>/go in wherever you store your persistent ENVs in places like ~/.bashrc, ~/.profile or ~/.bash_profile depending on the OS and system configuration.

Trying it out

If you want to try out some of your changes with your local docker install

  • docker-compose -f dev.yml up -d

This will start Open vSwitch and the plugin running inside a container!

Thanks

Thanks to the guys at Weave for writing their awesome plugin. We borrowed a lot of code from here to make this happen!

docker-ovs-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-ovs-plugin's Issues

Lengthen timer for netlink link for OVS bridge, exit 1 if retries fail.

Need to add a 2nd retry before to give more time for the netlink link from the OVS bridge being created to finish. If after 4 seconds total the added OVS bridge never gets the associated netlink link then exiting the driver since I believe its an underlying OS issue at that point that needs some troubleshooting.

INFO[0000] OVS network driver initialized successfully
DEBU[0024] Handshake completed
DEBU[0024] error retrieving new OVS bridge link [ ovsbr-docker0 ] likely a race issue between ovs and netlink, retrying in 1 second..
ERRO[0026] Error retrieving the new OVS bridge from netlink: Link not found
DEBU[0026] Error assigning address:[ 172.18.40.1/24 ] on bridge:[ ovsbr-docker0 ]  with an error of: Link not found
WARN[0026] No IP address found on bridge: [ ovsbr-docker0 ]: Link not found
2015/08/19 03:47:05 http: panic serving @: runtime error: invalid memory address or nil pointer dereference
goroutine 17 [running]:
net/http.func·011()
    /usr/local/go/src/net/http/server.go:1130 +0xbb
github.com/gopher-net/docker-ovs-plugin/plugin/ovs.(*driver).interfaceUP(0xc208074000, 0x8aa550, 0xd, 0x0, 0x0)
    /home/brent/go/src/github.com/gopher-net/docker-ovs-plugin/plugin/ovs/driver.go:423 +0x8e
github.com/gopher-net/docker-ovs-plugin/plugin/ovs.(*driver).createEndpoint(0xc208074000, 0x7f8dd726fcb8, 0xc2080750e0, 0xc20801fd40)

Error response from daemon: NetworkDriver.CreateNetwork: Number of Replies should be atleast equal to number of Operations

I could successfully execute till step 4. Step 5, i.e. docker network create -d ovs mynet is consistently failing with this error: "Error response from daemon: NetworkDriver.CreateNetwork: Number of Replies should be atleast equal to number of Operations"

I tried debugging it, below are the logs of the container 'ubuntu_plugin_1' formed after step 4.

root@kdhokte-0p8tj:/home/ubuntu# docker logs ubuntu_plugin_1
ERRO[0000] could not connect to openvswitch on port [ 6640 ]: dial tcp 127.0.0.1:6640: getsockopt: connection refused. Retrying in 5 seconds
DEBU[0007] root group found. gid: 0
2016/12/26 14:11:37 rpc2: client protocol error: unexpected EOF
DEBU[0239] Create network request: &{NetworkID:baf387437952422220c26b6efaa5963476cd27fc0cedf8d9b56bd99e03cdf8e7 Options:map[com.docker.network.enable_ipv6:false com.docker.network.generic:map[]] IPv4Data:[0xc820107800] IPv6Data:[]}
DEBU[0239] Initializing bridge for network baf387437952422220c26b6efaa5963476cd27fc0cedf8d9b56bd99e03cdf8e7
ERRO[0239] error creating ovs bridge [ ovsbr-baf38 ] : [ Number of Replies should be atleast equal to number of Operations ]
DEBU[0754] Create network request: &{NetworkID:4dd93729ae2db431bc09ddde48880cac14b84592f0cf5518bc7721b77fc4da6d Options:map[com.docker.network.generic:map[] com.docker.network.enable_ipv6:false] IPv4Data:[0xc8201079c0] IPv6Data:[]}
DEBU[0754] Initializing bridge for network 4dd93729ae2db431bc09ddde48880cac14b84592f0cf5518bc7721b77fc4da6d
ERRO[0754] error creating ovs bridge [ ovsbr-4dd93 ] : [ Number of Replies should be atleast equal to number of Operations ]
DEBU[1027] Create network request: &{NetworkID:daa414c03d9638c913b36bd3fc2d12bbd25c5c7adf4a8755b3c2a4262cc67c15 Options:map[com.docker.network.enable_ipv6:false com.docker.network.generic:map[]] IPv4Data:[0xc820107b80] IPv6Data:[]}
DEBU[1027] Initializing bridge for network daa414c03d9638c913b36bd3fc2d12bbd25c5c7adf4a8755b3c2a4262cc67c15
ERRO[1027] error creating ovs bridge [ ovsbr-daa41 ] : [ Number of Replies should be atleast equal to number of Operations ]

Running this on Ubuntu 14.04 with docker version 1.12.5, build 7392c3b. Any help is appreciated.

"Err":"Could not find a link for the OVS bridge named ovsbr-xxxxxx"

I am running docker 1.9.1 build a34a1d5 on ubuntu 14.04. When i try to create a docker network with the ovs plugin ,it is giving me an error.

docker network create -d ovs ovsnet

Error response from daemon: Plugin Error: NetworkDriver.CreateNetwork, {"Err":"Could not find a link for the OVS bridge named ovsbr-dd01c"}

Is this docker version error or there is something wrong happened with the plugin because initially it was working fine with the docker version 1.9.1

please take this down

how exactly are you supposed to configure host networking from a docker container?

Failed in prefunc: failed to get link by name "eth0-xxx": Link not found

If you spin up a big batch of containers, eventually a race condition occurs. Im guessing but it seems like an issue with libnetwork and the plugin both trying to lock the nspid filehandle at the same time. Haven't investigated yet.

Replicate the issue by pasting a few dozen containers into your console and eventually containers stop starting and go to created status:

docker run -itd busybox
docker run -itd busybox
docker run -itd busybox
# add a couple dozen or so and paste at once

*Plugin:

ERRO[0046] Failed to get the nspid from docker Unable to find container: f52e5b76687d
ERRO[0046] Errors encountered adding routes to the port [ eth0-dc0ef ]: bad file descriptor

*Docker Daemon:

ERRO[0047] Handler for POST /containers/{name:.*}/start returned error: Cannot start container f52e5b76687dbe8c93750aa57aaaed53595b9d4f22f24771ad702bbec2aa37fe: failed sandbox add: failed to add interface eth0-dc0ef to sandbox: failed in prefunc: failed to get link by name "eth0-dc0ef": Link not found
ERRO[0047] HTTP Error                                    err=Cannot start container f52e5b76687dbe8c93750aa57aaaed53595b9d4f22f24771ad702bbec2aa37fe: failed sandbox add: failed to add interface eth0-dc0ef to sandbox: failed in prefunc: failed to get link by name "eth0-dc0ef": Link not found statusCode=404

OVSDB transaction logs:
https://gist.github.com/nerdalert/c0645d9eae392190f5ff

Add moar diagramz

Drawings are like cat memes, no such thing as too many.
Thinking at least:
-Veth pair and OVS bridge relationship.
-Larger deployment scenario(s). Flat, spine/leaf etc.

Incorrect Usage with -mode=flat

Steps to reproduce:

  1. Build from Dockerfile:
$ docker build -t ovs-plugin .
  1. Run in flat mode:
$ docker run -v /run/docker/plugins:/run/docker/plugins -v /var/run/docker.sock:/varun/docker.sock --net=host --privileged ovs-plugin --gateway=192.168.1.1 --bridge-subnet=192.168.1.0/24 -mode=flat
Incorrect Usage.

NAME:
   don - Docker Open vSwitch Networking

USAGE:
   don [global options] command [command options] [arguments...]

VERSION:
   0.2

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d      enable debugging
   --help, -h       show help
   --version, -v    print the version

go dep failure...

When trying to build the plugin the "go dep ./..." points to an issue with the upstream libnetwork/iptables:

go get ./...

github.com/docker/libnetwork/iptables
../../github.com/docker/libnetwork/iptables/firewalld.go:75: cannot use c.sysconn.Object(dbusInterface, dbus.ObjectPath(dbusPath)) (type dbus.BusObject) as type *dbus.Object in assignment: need type assertion

More setup details here: https://gist.github.com/FlorianOtel/eb5926c8a640b4cd6f57

panic: could not connect to open vswitch

I am trying to setup the environment. However I got an error:

could not connect to openvswitch on port [ 6640 ]: dial tcp 127.0.0.1:6640: getsockopt: connection refused. Retrying in 5 seconds 
panic: could not connect to open vswitch

Did I miss something?

Thanks!

Crash in plugin due to concurrent map writes

docker-ovs-plugin version 0.2

Looks like there are a few global maps that are not protected with mutex's

ovsdbCache map[string]map[string]libovsdb.Row

I was running an experiment with many containers starting and stopping, the plugin panic'd with the following backtrace:

fatal error: concurrent map writes

goroutine 3521 [running]:
runtime.throw(0x8283a9, 0x15)
	/usr/local/go/src/runtime/panic.go:566 +0x95 fp=0xc4202136d8 sp=0xc4202136b8
runtime.mapassign1(0x7b2e40, 0xc4200dcea0, 0xc420213830, 0xc420213860)
	/usr/local/go/src/runtime/hashmap.go:458 +0x8ef fp=0xc4202137c0 sp=0xc4202136d8
github.com/gopher-net/docker-ovs-plugin/ovs.populateCache(0xc420110c60)
	/go/src/github.com/gopher-net/docker-ovs-plugin/ovs/ovsdb.go:156 +0x307 fp=0xc420213940 sp=0xc4202137c0
github.com/gopher-net/docker-ovs-plugin/ovs.OvsdbNotifier.Update(0x78c4a0, 0xc4204278c0, 0xc420110c60)
	/go/src/github.com/gopher-net/docker-ovs-plugin/ovs/ovsdb.go:36 +0x5b fp=0xc420213978 sp=0xc420213940
github.com/gopher-net/docker-ovs-plugin/ovs.(*OvsdbNotifier).Update(0xa0a810, 0x78c4a0, 0xc4204278c0, 0xc420110c60)
	<autogenerated>:1 +0x6a fp=0xc4202139b8 sp=0xc420213978
github.com/socketplane/libovsdb.update(0xc4200de0e0, 0xc420180300, 0x2, 0x4, 0xc420500230, 0x0, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/socketplane/libovsdb/client.go:133 +0x24b fp=0xc420213a68 sp=0xc4202139b8
runtime.call64(0xc4200dc330, 0x858e90, 0xc4201803c0, 0x2800000038)
	/usr/local/go/src/runtime/asm_amd64.s:480 +0x4c fp=0xc420213ab8 sp=0xc420213a68
reflect.Value.call(0x7af420, 0x858e90, 0x13, 0x821de5, 0x4, 0xc420213ee0, 0x3, 0x3, 0x0, 0x7f7940, ...)
	/usr/local/go/src/reflect/value.go:434 +0x5c8 fp=0xc420213e08 sp=0xc420213ab8
reflect.Value.Call(0x7af420, 0x858e90, 0x13, 0xc420213ee0, 0x3, 0x3, 0x0, 0x0, 0x0)
	/usr/local/go/src/reflect/value.go:302 +0xa4 fp=0xc420213e70 sp=0xc420213e08
github.com/cenkalti/rpc2.(*Client).readRequest.func1(0xc4200e2080, 0xc4200de0e0, 0x78c4a0, 0xc42019e2e0, 0x197, 0x7806c0, 0xc420500230, 0x16, 0x0, 0xc42022d7c8, ...)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/cenkalti/rpc2/client.go:151 +0x133 fp=0xc420213f38 sp=0xc420213e70
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc420213f40 sp=0xc420213f38
created by github.com/cenkalti/rpc2.(*Client).readRequest
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/cenkalti/rpc2/client.go:169 +0x25b

goroutine 1 [IO wait, 87 minutes]:
net.runtime_pollWait(0x7ff12bfc4f18, 0x72, 0x0)
	/usr/local/go/src/runtime/netpoll.go:160 +0x59
net.(*pollDesc).wait(0xc420058bc0, 0x72, 0xc42010b8f8, 0xc420012160)
	/usr/local/go/src/net/fd_poll_runtime.go:73 +0x38
net.(*pollDesc).waitRead(0xc420058bc0, 0x9cd380, 0xc420012160)
	/usr/local/go/src/net/fd_poll_runtime.go:78 +0x34
net.(*netFD).accept(0xc420058b60, 0x0, 0x9cbc40, 0xc4201433e0)
	/usr/local/go/src/net/fd_unix.go:419 +0x238
net.(*UnixListener).accept(0xc420143160, 0xc420132cf0, 0xc42010b9e0, 0x66f69f)
	/usr/local/go/src/net/unixsock_posix.go:158 +0x32
net.(*UnixListener).Accept(0xc420143160, 0xc42010ba30, 0xc42010ba38, 0xc42010ba28, 0x5922dd)
	/usr/local/go/src/net/unixsock.go:229 +0x49
github.com/docker/docker/pkg/listenbuffer.(*defaultListener).Accept(0xc420143180, 0x8590b8, 0xc42000f180, 0x9d0680, 0xc420132cf0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/docker/docker/pkg/listenbuffer/buffer.go:71 +0x3f
net/http.(*Server).Serve(0xc42000ef00, 0x9cfc40, 0xc420143180, 0x0, 0x0)
	/usr/local/go/src/net/http/server.go:2273 +0x1ce
github.com/gopher-net/dknet.(*Handler).listenAndServe(0xc420143060, 0x822069, 0x4, 0x821cb5, 0x3, 0x822025, 0x4, 0x0, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/gopher-net/dknet/api.go:283 +0x1dc
github.com/gopher-net/dknet.(*Handler).ServeUnix(0xc420143060, 0x822025, 0x4, 0x821cb5, 0x3, 0x7, 0xc4200a0700)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/gopher-net/dknet/api.go:252 +0x68
main.Run(0xc4200a0790)
	/go/src/github.com/gopher-net/docker-ovs-plugin/main.go:44 +0xb6
github.com/codegangsta/cli.(*App).Run(0xc4200ca0c0, 0xc42000c0e0, 0x2, 0x2, 0xc420063950, 0x4052eb)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/codegangsta/cli/app.go:132 +0x5f8
main.main()
	/go/src/github.com/gopher-net/docker-ovs-plugin/main.go:30 +0x19b

goroutine 17 [syscall, 87 minutes, locked to thread]:
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2086 +0x1

goroutine 18 [IO wait]:
net.runtime_pollWait(0x7ff12bfc4fd8, 0x72, 0x3)
	/usr/local/go/src/runtime/netpoll.go:160 +0x59
net.(*pollDesc).wait(0xc4200de0d0, 0x72, 0xc42018fba8, 0xc420012160)
	/usr/local/go/src/net/fd_poll_runtime.go:73 +0x38
net.(*pollDesc).waitRead(0xc4200de0d0, 0x9cd380, 0xc420012160)
	/usr/local/go/src/net/fd_poll_runtime.go:78 +0x34
net.(*netFD).Read(0xc4200de070, 0xc42050a000, 0xfe00, 0xfe00, 0x0, 0x9cd380, 0xc420012160)
	/usr/local/go/src/net/fd_unix.go:243 +0x1a1
net.(*conn).Read(0xc4200e0000, 0xc42050a000, 0xfe00, 0xfe00, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:173 +0x70
encoding/json.(*Decoder).refill(0xc4200e4000, 0x7a98a0, 0xc42019e201)
	/usr/local/go/src/encoding/json/stream.go:152 +0xfa
encoding/json.(*Decoder).readValue(0xc4200e4000, 0x0, 0x0, 0x671ccb)
	/usr/local/go/src/encoding/json/stream.go:128 +0x198
encoding/json.(*Decoder).Decode(0xc4200e4000, 0x77ea40, 0xc4200e8020, 0xc420500230, 0x16)
	/usr/local/go/src/encoding/json/stream.go:57 +0x8e
github.com/cenkalti/rpc2/jsonrpc.(*jsonCodec).ReadHeader(0xc4200e8000, 0xc4200c7740, 0xc4200c7760, 0x0, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/cenkalti/rpc2/jsonrpc/jsonrpc.go:93 +0x70
github.com/cenkalti/rpc2.(*Client).readLoop(0xc4200de0e0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/cenkalti/rpc2/client.go:79 +0x116
github.com/cenkalti/rpc2.(*Client).Run(0xc4200de0e0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/cenkalti/rpc2/client.go:54 +0x2b
created by github.com/socketplane/libovsdb.Connect
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/socketplane/libovsdb/client.go:55 +0x631

goroutine 19 [chan receive, 87 minutes]:
github.com/socketplane/libovsdb.handleDisconnectNotification(0xc4200de0e0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/socketplane/libovsdb/client.go:249 +0x49
created by github.com/socketplane/libovsdb.Connect
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/socketplane/libovsdb/client.go:56 +0x656

goroutine 6 [chan receive]:
github.com/gopher-net/docker-ovs-plugin/ovs.(*ovsdber).monitorBridges(0xc420132318)
	/go/src/github.com/gopher-net/docker-ovs-plugin/ovs/ovsdb.go:122 +0x71
created by github.com/gopher-net/docker-ovs-plugin/ovs.(*ovsdber).initDBCache
	/go/src/github.com/gopher-net/docker-ovs-plugin/ovs/ovsdb.go:66 +0x2b9

goroutine 7 [syscall]:
syscall.Syscall6(0x2c, 0x7, 0xc42052ee60, 0x20, 0x0, 0xc42052ee34, 0xc, 0xc420186e10, 0x10, 0xc42052ee60)
	/usr/local/go/src/syscall/asm_linux_amd64.s:44 +0x5
syscall.sendto(0x7, 0xc42052ee60, 0x20, 0x20, 0x0, 0xc42052ee34, 0xc40000000c, 0xc42052ee60, 0xc420384690)
	/usr/local/go/src/syscall/zsyscall_linux_amd64.go:1729 +0x80
syscall.Sendto(0x7, 0xc42052ee60, 0x20, 0x20, 0x0, 0x9cbf40, 0xc42052ee28, 0xc4204cd8f0, 0xc4204cd900)
	/usr/local/go/src/syscall/syscall_unix.go:265 +0x92
github.com/vishvananda/netlink/nl.(*NetlinkSocket).Send(0xc42052ee20, 0xc420186e10, 0xc42052ee20, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/vishvananda/netlink/nl/nl_linux.go:333 +0x7c
github.com/vishvananda/netlink/nl.(*NetlinkRequest).Execute(0xc420186e10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/vishvananda/netlink/nl/nl_linux.go:215 +0xfd
github.com/vishvananda/netlink.LinkDel(0x9ce200, 0xc42055ff80, 0x4, 0xc4200e27c0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/vishvananda/netlink/link_linux.go:432 +0xfe
github.com/gopher-net/docker-ovs-plugin/ovs.(*Driver).Leave(0xc420132300, 0xc420186cf0, 0xc420186cf0, 0x0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/ovs/driver.go:171 +0x1b6
github.com/gopher-net/dknet.(*Handler).initMux.func9(0x9cfec0, 0xc420065ee0, 0xc42034a0f0)
	/go/src/github.com/gopher-net/docker-ovs-plugin/Godeps/_workspace/src/github.com/gopher-net/dknet/api.go:233 +0xb4
net/http.HandlerFunc.ServeHTTP(0xc420136dc0, 0x9cfec0, 0xc420065ee0, 0xc42034a0f0)
	/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.(*ServeMux).ServeHTTP(0xc420132c00, 0x9cfec0, 0xc420065ee0, 0xc42034a0f0)
	/usr/local/go/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc42000ef00, 0x9cfec0, 0xc420065ee0, 0xc42034a0f0)
	/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42000f180, 0x9d05c0, 0xc42012d480)
	/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2293 +0x44d

start plugin fial

when docker compose up -d , the opt_plugin_1 claim
[root@niao-node-1 opt]# docker logs opt_plugin_1
ERRO[0000] could not connect to openvswitch on port [ 6640 ]: dial tcp 127.0.0.1:6640: getsockopt: connection refused. Retrying in 5 seconds
[root@niao-node-1 opt]# ls

[root@niao-node-1 opt]# docker info
Containers: 2
Images: 61
Server Version: 1.9.1
Storage Driver: devicemapper
Pool Name: docker-253:0-524456-pool
Pool Blocksize: 65.54 kB
Base Device Size: 107.4 GB
Backing Filesystem:
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 3.16 GB
Data Space Total: 107.4 GB
Data Space Available: 23.71 GB
Metadata Space Used: 4.035 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.143 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.107-RHEL7 (2015-10-14)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 2
Total Memory: 1.784 GiB
Name: niao-node-1
ID: JQMZ:SQX4:Z6K3:LN5N:L3FI:A6WL:ISMC:QB5B:LWRM:HWLQ:7VXQ:MPXY
[root@niao-node-1 opt]# docker -v
Docker version 1.9.1, build a34a1d5

Update Readme

Todo: update readme. Need example usage without Compose.

Just running the daemon + the plugin returns docker network create -d ovs my net returns a 404.

Tried the compose and got this:

(='o'=)[root@deb8-150:docker-ovs-plugin$]# docker-compose up -d
Pulling ovs (socketplane/openvswitch:2.3.2)...
2.3.2: Pulling from socketplane/openvswitch
35a6470d0f7d: Pull complete
63536bce8d2b: Pull complete
2bf521d9f3d0: Pull complete
176b6f31a254: Pull complete
2e7d304183d9: Pull complete
90383402eb2b: Pull complete
73185b4131bd: Pull complete
5431aeeebe32: Pull complete
90256da21143: Pull complete
3848a819cf44: Pull complete
e0d5509fe808: Pull complete
c67176847a85: Pull complete
b0d63abd901d: Pull complete
f4b458c14fe0: Pull complete
89aabc43f9ef: Pull complete
21b5a86b035d: Pull complete
36a8f5c4784e: Pull complete
Digest: sha256:4b20d44aaffbdba10dbf3fa51ae31284400aeb0cda1e7bcf9a966a00fde64de8
Status: Downloaded newer image for socketplane/openvswitch:2.3.2
Creating dockerovsplugin_ovs_1...
Pulling plugin (gopher-net/ovs-plugin:latest)...
Pulling repository docker.io/gopher-net/ovs-plugin
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 32, in main
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 34, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 66, in perform_command
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 470, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.project", line 230, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 321, in execute_convergence_plan
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 209, in create_container
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 237, in ensure_image_exists
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 708, in pull
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 37, in stream_output
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 50, in print_output_event
compose.progress_stream.StreamOutputError: Error: image gopher-net/ovs-plugin:latest not found

cannot finish install

Hi,

I have alway met the following error when I start "./docker-ovs-plugin -d"
How could I solve the issue?

vagrant@ovsnode:/home/vagrant# ./docker-ovs-plugin -d
DEBU[0000] socket file [ /usr/share/docker/plugins/ovs.sock ] already exists, deleting..
DEBU[0000] Plugin socket path is [ /usr/share/docker/plugins/ ] with a file handle [ ovs.sock ]
INFO[0000] OVSDB network driver initialized

ovs-plugin is very interesting!!

thx,

Verify OVS bridge is created by the plugin at docker run for the first container

Hey @Runseb can you double check your OVS bridge isn't created by default. I think I saw a readme update that has it being created manually. There is a br create method in ovs_bridge.go func (driver *driver) setupBridge() that should create it. If you could double check that was or wasn't working that would be awesome. Below are before and afters and output.

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:58:1c:01 brd ff:ff:ff:ff:ff:ff
    inet 172.16.86.150/24 brd 172.16.86.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe58:1c01/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:58:1c:0b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.250/24 brd 192.168.1.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe58:1c0b/64 scope link
       valid_lft forever preferred_lft forever
16: ovs-system@NONE: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether 0e:88:46:2b:39:e8 brd ff:ff:ff:ff:ff:ff

OVS config

$ ovs-vsctl show

45045b76-ec16-4828-bafb-07b138f6a565
    Manager "ptcp:6640"
    ovs_version: "2.3.0"

Start the plugin with defaults, ovsbr-docker0 with an ip of 172.18.40.1/24 (containers land in that network)

./docker-ovs-plugin  -d

or from source

git clone https://github.com/gopher-net/docker-ovs-plugin.git
cd docker-ovs-plugin/plugin/
# get dependancies
go get ./...
go run main.go -d

Start Docker (note, docker0 still gets created. I am not sure how to disable that yet. @dave-tucker might know. Since we are passing what we want as the default bridge, it would make sense to not create another default bridge that is unused or worse overlapping. Whatever the name passed to the default-network should be what is setup in OVS.

docker -d -D --default-network=ovs:ovsbr-docker0

Start a container

docker run -i -t --rm busybox

After a container starts, the network create is called and the default bridge for the plugin (ovsbr-docker0) is created and assigned an L3 ip addr. (Note: we need to add a masquerade option there to enable a NAT.)

$ ifconfig
docker0   Link encap:Ethernet  HWaddr b2:d1:59:e3:94:d1
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::b0d1:59ff:fee3:94d1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:648 (648.0 B)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:58:1c:01
          inet addr:172.16.86.150  Bcast:172.16.86.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe58:1c01/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10526 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5933 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1099310 (1.0 MiB)  TX bytes:939698 (917.6 KiB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0c:29:58:1c:0b
          inet addr:192.168.1.250  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe58:1c0b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1286098 errors:66 dropped:186 overruns:0 frame:0
          TX packets:8144 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:765846208 (730.3 MiB)  TX bytes:560943 (547.7 KiB)
          Interrupt:19 Base address:0x2080

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1751 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1751 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:913292 (891.8 KiB)  TX bytes:913292 (891.8 KiB)

ovs-veth0-c3caa Link encap:Ethernet  HWaddr 9e:8e:dc:75:42:7d
          inet6 addr: fe80::9c8e:dcff:fe75:427d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:508 (508.0 B)  TX bytes:836 (836.0 B)

ovsbr-docker0 Link encap:Ethernet  HWaddr d6:6a:3c:03:92:44
          inet addr:172.18.40.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::d46a:3cff:fe03:9244/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:508 (508.0 B)  TX bytes:508 (508.0 B)

# OVS

# ovs-vsctl show
45045b76-ec16-4828-bafb-07b138f6a565
    Manager "ptcp:6640"
        is_connected: true
    Bridge "ovsbr-docker0"
        Port "ovsbr-docker0"
            Interface "ovsbr-docker0"
                type: internal
        Port "ovs-veth0-c3caa"
            Interface "ovs-veth0-c3caa"
    ovs_version: "2.3.0"

Moar Containerz

containerize and get the host OS ovsdb manager connection

Update binary

Move the plugin path for the plugin ovs.sock file handle from /usr/share/docker/plugin/ to /run/docker/plugins/ovs.sock.

--default-network flag is not defined

Do we have any requirement on Docker experimental version to run this plugin? I get a error of --default-network flag.

sudo docker -d --default-network=ovs:ovsbr-docker0

Warning: '-d' is deprecated, it will be removed soon. See usage.
flag provided but not defined: --default-network
See 'docker --help'.

docker version

Client:
Version: 1.9.0-dev
API version: 1.22
Go version: go1.4.3
Git commit: ccf5b60
Built: Fri Oct 16 19:11:01 UTC 2015
OS/Arch: linux/amd64
Experimental: true
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.