Skip to content

Commit 6fabb4e

Browse files
committed
Create swarm_plus_netplugin.md
1 parent db03bce commit 6fabb4e

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

docs/swarm_plus_netplugin.md

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
## Using Netplugin with Docker Swarm
2+
3+
This document describes how to use netplugin with docker swarm.
4+
Docker Swarm is a scheduler that schedules containers to multiple machines. Netplugin is a docker network plugin that provides multi host networking.
5+
6+
Docker + Swarm + Netplugin == Awesome!!
7+
8+
## Getting started
9+
10+
Checkout netplugin tree and bringup vagrant setup
11+
```
12+
mkdir -p github.com/contiv/
13+
cd github/contiv
14+
git clone -b demo https://github.com/contiv/netplugin.git
15+
CONTIV_NODES=2 make build demo
16+
```
17+
This brings up two VM cluster with docker, swarm and netplugin/netmaster running
18+
To make docker commands start using swarm instead of docker, set the following environment variable.
19+
```
20+
export DOCKER_HOST=tcp://192.168.2.10:2375
21+
```
22+
Now, you should be able to see the information about the cluster
23+
```
24+
$ docker info
25+
Containers: 0
26+
Images: 5
27+
Engine Version:
28+
Role: primary
29+
Strategy: spread
30+
Filters: affinity, health, constraint, port, dependency
31+
Nodes: 2
32+
netplugin-node1: 192.168.2.10:2385
33+
└ Containers: 0
34+
└ Reserved CPUs: 0 / 4
35+
└ Reserved Memory: 0 B / 2.051 GiB
36+
└ Labels: executiondriver=native-0.2, kernelversion=4.0.0-040000-generic, operatingsystem=Ubuntu 15.04, storagedriver=devicemapper
37+
netplugin-node2: 192.168.2.11:2385
38+
└ Containers: 0
39+
└ Reserved CPUs: 0 / 4
40+
└ Reserved Memory: 0 B / 2.051 GiB
41+
└ Labels: executiondriver=native-0.2, kernelversion=4.0.0-040000-generic, operatingsystem=Ubuntu 15.04, storagedriver=devicemapper
42+
CPUs: 8
43+
Total Memory: 4.103 GiB
44+
Name: netplugin-node1
45+
No Proxy: 192.168.0.0/16,localhost,127.0.0.0/8
46+
```
47+
48+
Next, you can see if there are any containers running in the cluster
49+
```
50+
$ docker ps
51+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
52+
```
53+
54+
When netplugin/netmaster start up, they create two networks as below
55+
```
56+
$ contivctl network list
57+
Listing all networks for tenant default
58+
Network Public Encap Subnet Gateway
59+
private No vxlan 10.1.0.0/16 10.1.254.254
60+
public Yes vlan 192.168.1.0/24 192.168.1.254
61+
```
62+
63+
you can run containers and attach them to one of these networks as below.
64+
```
65+
$ docker run -itd --publish-service foo.private ubuntu bash
66+
f291e269b45a5877f6fc952317feb329e12a99bda3a44a740b4c3307ef87954c
67+
```
68+
69+
you can verify its running and has the correct service name
70+
71+
```
72+
$ docker ps
73+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
74+
f291e269b45a ubuntu "bash" 27 seconds ago Up 24 seconds netplugin-node2/elegant_shaw
75+
76+
$ docker inspect f291e269b45a | grep -i "net\|ip\|mac\|service"
77+
"NetworkSettings": {
78+
"GlobalIPv6Address": "",
79+
"GlobalIPv6PrefixLen": 0,
80+
"IPAddress": "10.1.0.1",
81+
"IPPrefixLen": 16,
82+
"IPv6Gateway": "",
83+
"LinkLocalIPv6Address": "",
84+
"LinkLocalIPv6PrefixLen": 0,
85+
"MacAddress": "",
86+
"NetworkID": "56d09d456d83766d3709408f6f4cc95dfc4ea87731936cbad60f215e57d04a2e",
87+
"SandboxKey": "/var/run/docker/netns/3dce9fcdb134",
88+
"SecondaryIPAddresses": null,
89+
"SecondaryIPv6Addresses": null
90+
"IP": "192.168.2.11",
91+
"Name": "netplugin-node2",
92+
"NetworkMode": "default",
93+
"IpcMode": "",
94+
"PublishService": "foo.private",
95+
"NetworkDisabled": false,
96+
"MacAddress": "",
97+
```
98+
99+
You can verify netplugin has automatically created the endpoint groups using following command
100+
```
101+
$ contivctl group list
102+
Listing all endpoint groups for tenant default
103+
Group Network Policies
104+
---------------------------------------------------
105+
foo.private private --
106+
bar.private private --
107+
```
108+
109+
Or you can check netplugin oper state to verify endpoints have been created
110+
```
111+
$ curl -s localhost:9999/endpoints | python -mjson.tool
112+
[
113+
{
114+
"attachUUID": "",
115+
"contName": "00b913565f884adf9d75f0062e86df2f69fd806ac9ce0b2e32aca6331dbe13e8",
116+
"contUUID": "",
117+
"homingHost": "netplugin-node1",
118+
"id": "private-00b913565f884adf9d75f0062e86df2f69fd806ac9ce0b2e32aca6331dbe13e8",
119+
"intfName": "",
120+
"ipAddress": "10.1.0.2",
121+
"macAddress": "02:02:0a:01:00:02",
122+
"netID": "private",
123+
"portName": "port1",
124+
"vtepIP": ""
125+
},
126+
{
127+
"attachUUID": "",
128+
"contName": "541d02264d1b1fd5989b188e1073e077c3a3ef77ec0cc5fa35dfd78f9808ef31",
129+
"contUUID": "",
130+
"homingHost": "netplugin-node2",
131+
"id": "private-541d02264d1b1fd5989b188e1073e077c3a3ef77ec0cc5fa35dfd78f9808ef31",
132+
"intfName": "",
133+
"ipAddress": "10.1.0.1",
134+
"macAddress": "02:02:0a:01:00:01",
135+
"netID": "private",
136+
"portName": "port1",
137+
"vtepIP": ""
138+
}
139+
]
140+
```

0 commit comments

Comments
 (0)