>_Docker Engine e Weave Network – VLAN’s

weave-1

Neste tutorial, irei abordar a utilização do Weave Network em containers Docker Engine.
Para quem não conhece o Weave Network, recomendo que leia o tutorial abaixo.

>_Cluster CentOS 7.2 – Instalando o Docker Engine e o Weave Network – 1.5

Ambiente:

Duas Máquinas Virtuais com o Docker Engine Instalado e o Weave Network já instalado e configurado.

weave1 – 192.168.0.151
weave2 – 192.168.0.152

Host weave1.
Passo 1 – Subindo um container Ubuntu com o ip 10.0.5.1/24.

[root@weave1 ~]# weave run 10.0.5.1/24  -tdi ubuntu
5fd07ea5c4066b4df6ed7773352f6e24ba490bc23a0d6436dc5c49ebeae5f164

Host weave2.
Passo 2 – Subindo um container Ubuntu com o ip 10.0.5.2/24.

[root@weave2 ~]# weave run 10.0.5.2/24  -tdi ubuntu
aa3aac6bb99fb4648c1ad7d68f12ad217b8d0f39bb7f48552943ef16429f347e

Passo 3 – Verificando o ID do container com o comando docker ps.
Host weave1.

[root@weave1 ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
5fd07ea5c406        ubuntu                       "/bin/bash"              34 seconds ago      Up 34 seconds                           happy_panini
f3dcb9af2826        weaveworks/plugin:1.4.5      "/home/weave/plugin"     About an hour ago   Up About an hour                        weaveplugin
7d8456e2ab14        weaveworks/weaveexec:1.4.5   "/home/weave/weavepro"   About an hour ago   Up About an hour                        weaveproxy
784aec521a87        weaveworks/weave:1.4.5       "/home/weave/weaver -"   About an hour ago   Up About an hour                        weave

Passo 4 – Entrando no container com o comando docker attach, e verificando as interfaces de rede.
Host weave1.

[root@weave1 ~]# docker attach 5fd07ea5c406
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02  
          inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 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:648 (648.0 B)  TX bytes:648 (648.0 B)

ethwe     Link encap:Ethernet  HWaddr 2a:3c:d4:0a:52:53  
          inet addr:10.0.5.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::283c:d4ff:fe0a:5253/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1410  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:928 (928.0 B)  TX bytes:970 (970.0 B)

Passo 5 – Executando o ping de dentro do container que está no Host weave1 para o container que está no Host weave2.

root@5fd07ea5c406:/# ping 10.0.5.2
PING 10.0.5.2 (10.0.5.2) 56(84) bytes of data.
64 bytes from 10.0.5.2: icmp_seq=1 ttl=64 time=2.03 ms
64 bytes from 10.0.5.2: icmp_seq=2 ttl=64 time=1.12 ms

Passo 6 – Verificando o ID do container com o comando docker ps.
Host weave2.

[root@weave2 ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED              STATUS              PORTS               NAMES
aa3aac6bb99f        ubuntu                       "/bin/bash"              About a minute ago   Up About a minute                       gigantic_hoover
2642147068c3        weaveworks/plugin:1.4.5      "/home/weave/plugin"     About an hour ago    Up About an hour                        weaveplugin
1276d3840c61        weaveworks/weaveexec:1.4.5   "/home/weave/weavepro"   About an hour ago    Up About an hour                        weaveproxy
4d875aed4598        weaveworks/weave:1.4.5       "/home/weave/weaver -"   About an hour ago    Up About an hour                        weave

Passo 7 – Entrando no container com o comando docker attach, e verificando as interfaces de rede.
Host weave2.

[root@weave2 ~]# docker attach aa3aac6bb99f
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02  
          inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 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:1296 (1.2 KB)  TX bytes:648 (648.0 B)

ethwe     Link encap:Ethernet  HWaddr da:ac:44:2c:b8:ee  
          inet addr:10.0.5.2  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::d8ac:44ff:fe2c:b8ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1410  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:578 (578.0 B)  TX bytes:620 (620.0 B)

Passo 8 – Executando o ping de dentro do container que está no Host weave2 para o container que está no Host weave1.

root@aa3aac6bb99f:/# ping 10.0.5.1
PING 10.0.5.1 (10.0.5.1) 56(84) bytes of data.
64 bytes from 10.0.5.1: icmp_seq=1 ttl=64 time=1.34 ms
64 bytes from 10.0.5.1: icmp_seq=2 ttl=64 time=1.03 ms

Passo 9 – Removendo o ip 10.0.5.1/24 do container de ID 5fd07ea5c406 que está no Host weave1.

[root@weave1 ~]# weave detach 10.0.5.1/24  5fd07ea5c406
10.0.5.1

Passo 10 – Verificando.

[root@ba-vm-www-redis1 ~]# docker attach 5fd07ea5c406

root@5fd07ea5c406:/# ifconfig 
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02  
          inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 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:1296 (1.2 KB)  TX bytes:648 (648.0 B)

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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Passo 11 – Fixando novamente o ip 10.0.5.1/24 no container de ID 5fd07ea5c406.

[root@ba-vm-www-redis1 ~]# weave attach 10.0.5.1/24  5fd07ea5c406
10.0.5.1

Passo 12 – Verificando.

[root@weave1 ~]# docker attach 5fd07ea5c406
root@5fd07ea5c406:/# ifconfig 
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02  
          inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 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:1296 (1.2 KB)  TX bytes:648 (648.0 B)

ethwe     Link encap:Ethernet  HWaddr da:ac:44:2c:b8:ee  
          inet addr:10.0.5.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::d8ac:44ff:fe2c:b8ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1410  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:578 (578.0 B)  TX bytes:620 (620.0 B)

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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Passo 13 – Verificando a comunicação entre os Host weave1 e weave2 através da interface weave.
Host weave1.

weave: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1410
        inet 10.0.1.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::6060:76ff:fe88:3d31  prefixlen 64  scopeid 0x20
        ether 62:60:76:88:3d:31  txqueuelen 0  (Ethernet)
        RX packets 42  bytes 2604 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11  bytes 774 (774.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Host weave2.

weave: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1410
        inet 10.0.2.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::4c86:4aff:fe54:1098  prefixlen 64  scopeid 0x20
        ether 4e:86:4a:54:10:98  txqueuelen 0  (Ethernet)
        RX packets 40  bytes 2472 (2.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11  bytes 774 (774.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@weave1 ~]# ping 10.0.2.1
PING 10.0.2.1 (10.0.2.1) 56(84) bytes of data.
^C
--- 10.0.2.1 ping statistics ---

Passo 14 – Deixando em exposição a rede 10.0.2.0/24 no Host weave1.

[root@weave1 ~]# weave expose 10.0.2.2/24
10.0.2.2

Passo 15 – Fazendo o teste de ping entre o Host weave1 e o host weave2.

[root@ba-vm-www-redis1 ~]# ping 10.0.2.1
PING 10.0.2.1 (10.0.2.1) 56(84) bytes of data.
64 bytes from 10.0.2.1: icmp_seq=1 ttl=64 time=2.85 ms
64 bytes from 10.0.2.1: icmp_seq=2 ttl=64 time=1.25 ms

Passo 15 – Fazendo o mesmo na Host weave2.

[root@ba-vm-www-redis2 ~]# ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data.
^C
--- 10.0.1.1 ping statistics ---
[root@weave2 ~]# weave expose 10.0.1.2/24
10.0.1.2
[root@weave2 ~]# ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data.
64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=2.17 ms
64 bytes from 10.0.1.1: icmp_seq=2 ttl=64 time=1.04 ms

Feito.

Fonte:
http://docs.weave.works/weave/latest_release/index.html

>_Docker Engine e Weave Network – VLAN’s
Tagged on:

One thought on “>_Docker Engine e Weave Network – VLAN’s

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

%d blogueiros gostam disto: