Skip to content

Commit c73cd5a

Browse files
committed
Updating Service Binding docs
1 parent 3048dd8 commit c73cd5a

3 files changed

Lines changed: 111 additions & 65 deletions

File tree

docs/ServiceBindingDemo.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<h1>Service Binding with Netplugin</h1>
2+
3+
Services are automatically made discoverable by netplugin via a DNS provider when they are brought up. SkyDNS is the preferred and default DNS provider(currently) when using netplugin.
4+
5+
The diagram below is a representation of the Service binding architecture offered by netplugin:
6+
![Service Binding Model](./ServiceBindingModel.png)
7+
8+
Service binding states are modified during the following triggers:
9+
10+
1. DNS entry is automatically created when the container is brought up
11+
2. DNS entry is removed in the following conditions:
12+
- when the container is stopped/removed
13+
- when the host on which the container resides crashes
14+
15+
<h4> Trying out service binding features </h4>
16+
Refer to [README.md](README.md) to setup and bringup netplugin environment
17+
18+
Run `make demo`
19+
20+
The example here shows how services are discoverable within a tenant.
21+
22+
<h4>Creating a new tenant</h4>
23+
When netplugin is started, it creates a default tenant. You can check out service binding/discovery with just the default tenant. However, if you are interested in testing out how services are available within a tenant but isolated from other tenants, you can create a tenant using the following command:
24+
25+
`netctl tenant create --subnet-pool 100.1.0.0/16 --vlans 2000-2100 --vxlans 12000-12100 tenant1`
26+
27+
After the tenant creation, a DNS container is automatically created for service any DNS queries within the tenant
28+
```
29+
vagrant@netplugin-node1:~$ docker ps
30+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31+
dc70915bc835 skynetservices/skydns:latest "/skydns" 2 minutes ago Up 2 minutes 53/udp, 53/tcp tenant1dns
32+
213a588919b5 skynetservices/skydns:latest "/skydns" 4 minutes ago Up 4 minutes 53/tcp, 53/udp defaultdns
33+
```
34+
35+
<h4> Create a new network and endpoint to launch containers </h4>
36+
- Network creation
37+
- `netctl net create --tenant tenant1 --pkt-tag 12000 -s 100.1.2.0/24 --gateway 100.1.2.254 webnw`
38+
39+
- Endpoint creation
40+
- `netctl group create --tenant tenant1 webnw web`
41+
42+
<h4> Launch containers </h4>
43+
Launch services providing the DNS address in the --dns argument. You can find the DNS IP by inspecting the DNS container. It is generally the first IP address in the subnet provided for the network. Verify it by issuing the following command:
44+
45+
```
46+
vagrant@netplugin-node1:~$ docker exec -it tenant1dns ifconfig
47+
....
48+
49+
eth1 Link encap:Ethernet HWaddr 02:02:64:01:02:01
50+
inet addr: 100.1.2.1 Bcast:0.0.0.0 Mask:255.255.255.0
51+
inet6 addr: fe80::2:14ff:fe01:101/64 Scope:Link
52+
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
53+
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
54+
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
55+
collisions:0 txqueuelen:0
56+
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
57+
```
58+
59+
<h4>Launch services in the network</h4>
60+
```
61+
docker run -itd --net=web.webnw.tenant1 --dns=100.1.2.1 --dns-search=tenant1 --dns-search=webnw.tenant1 --name=web1 --hostname=web4 ubuntu /bin/bash
62+
docker run -itd --net=web.webnw.tenant1 --dns=100.1.2.1 --dns-search=tenant1 --dns-search=webnw.tenant1 --name=web2 --hostname=web4 ubuntu /bin/bash
63+
docker run -itd --net=web.webnw.tenant1 --dns=100.1.2.1 --dns-search=tenant1 --dns-search=webnw.tenant1 --name=web3 --hostname=web4 ubuntu /bin/bash
64+
```
65+
<h4>Verifying services using DNS</h4>
66+
Install tools like nslookup/dig to verify that all services are listed
67+
```
68+
root@web1:/# dig web.webnw.tenant1 SRV
69+
70+
; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> web.webnw.tenant1 SRV
71+
;; global options: +cmd
72+
;; Got answer:
73+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47572
74+
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 3
75+
76+
;; QUESTION SECTION:
77+
;web.webnw.tenant1. IN SRV
78+
79+
;; ANSWER SECTION:
80+
web.webnw.tenant1. 11 IN SRV 10 33 0 beb9e72d6f67.web.webnw.tenant1.
81+
web.webnw.tenant1. 11 IN SRV 10 33 0 7a3bec808f74.web.webnw.tenant1.
82+
web.webnw.tenant1. 11 IN SRV 10 33 0 44ad507b6786.web.webnw.tenant1.
83+
84+
;; ADDITIONAL SECTION:
85+
beb9e72d6f67.web.webnw.tenant1. 11 IN A 100.1.2.2
86+
7a3bec808f74.web.webnw.tenant1. 11 IN A 100.1.2.3
87+
44ad507b6786.web.webnw.tenant1. 11 IN A 100.1.2.4
88+
89+
;; Query time: 9 msec
90+
;; SERVER: 20.1.1.1#53(20.1.1.1)
91+
;; WHEN: Tue Dec 01 00:30:19 UTC 2015
92+
;; MSG SIZE rcvd: 272
93+
```
94+
95+
Ping using service name to verify that the hostname is resolved correctly.
96+
```
97+
root@web1:/# ping web
98+
PING web.webnw.tenant1 (20.1.1.5) 56(84) bytes of data.
99+
64 bytes from web3 (20.1.1.5): icmp_seq=1 ttl=64 time=0.291 ms
100+
64 bytes from web3 (20.1.1.5): icmp_seq=2 ttl=64 time=0.030 ms
101+
64 bytes from web3 (20.1.1.5): icmp_seq=3 ttl=64 time=0.255 ms
102+
64 bytes from web3 (20.1.1.5): icmp_seq=4 ttl=64 time=0.053 ms
103+
```
104+
105+
<h4> Explore your way through </h4>
106+
Here are some more scenarios to explore for services
107+
- Launch multiple networks in a tenant1 and all the services across these networks in the tenant are still discoverable
108+
- Launch multiple tenants and note that services in one tenant are not visible to other tenants thus providing isolation
109+
- Stop/Kill a service container and the DNS entries are updated to reflect this
110+
- If the host on which the service is residing is killed, all the service entries on the host expire after the TTL expires
111+

service-demo.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)