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

cluster-docker-weave

Para quem está acompanhando os tutoriais sobre Cluster para Containers Docker, este é o quinto tutorial da série. Nele Veremos um breve resumo sobre o que é Docker e sobre o que é o Weave Network. Em seguida será instalado em ambos os nodes (ba-vm-www-01 e ba-vm-www-02) o Docker Engine e o Weave Network.

Docker resumidamente.

Docker é uma plataforma Open Source escrito em Go, que é uma linguagem de programação de alto desempenho desenvolvida dentro do Google, que facilita a criação e administração de ambientes isolados.

Sua funcionalidade permite que adicione e que simplifique o uso dos recursos. Um containers Docker é basicamente, uma forma de isolamento do processo no sistemas operacional. A grosso modo seria quase como virtualização, porém mais leve e integrado diretamente no Host.

Porque usar Containers?

  1. Velocidade.
  2.  Boot em questão de segundos.
  3. Economia de recursos
  4. Os processos rodando dentro de um Container são vistos como um processo no sistema Host.
  5. É possível subir vários Containers ao mesmo tempo, consumindo o minimo de recursos do hardware físico ou virtual.

Diferenças entre o Sistema Operacional comum/virtualizado com o Container Docker.

Sistema Operacional.

  • Bootfs – Boot FileSystem.
  • Bottloader e Kernel.
  • Rootfs – Root Filesystem.
  • Restante dos arquivos do sistema.

Container Docker.

  • Bootfs – (LXC, aufs/btrfs) – Mesmo Kernel da máquina.
  • Rootfs – Sistema de arquivos.

Com o carregamento do rootfs, o Container Docker ficará pronto para execução.

Weave Network.

O Weave Network tem como função conectar os containers Docker entre diverso Hosts, permitindo a descoberta automática da rede, sem a necessidade da criação de rotas e/ou regras no firewall.

Vantagens de utilizar o Weave Network.

  • Distribuição automatica de um único endereço IP em toda cadeia do Cluster/Hosts.
  • Toda rede criada através do Weave Network é comutável dentro de uma rede privada através dos Switch’s virtuais.
  • Não há necessidade de um servidor DHCP.
  • Não há necessidade da configuração de um Overlay configurado. (etcd/consul).
  • Não há necessidade da configuração do OpenvSwitch.
  • Fácil implementação, comunicação e administração entre os Containers Docker em diferentes nuvens públicas/privadas.

Projeto Weave Network.

https://www.weave.works/products/weave-net/

Passo 1 – Atualizando os nodes (ba-vm-www-01 e ba-vm-www-02).

# yum update -y

Passo 2 – Criando o repositório Docker Engine.

# cd /etc/yum.repos.d/
# vim docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

Passo 3 – Instalando o Docker Engine em ambos os nodes (ba-vm-www-01 e ba-vm-www-02).

#  yum install docker-engine -y

Passo 4 – Habilitando o Docker para iniciar com no boot do sistema operacional.

# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

Pass 5 – Instalando o Weave Network em ambos os nodes (ba-vm-www-01 e ba-vm-www-02).

# yum install wget ntp -y
# wget -O /usr/local/bin/weave https://github.com/zettio/weave/releases/download/latest_release/weave
# chmod a+x /usr/local/bin/weave

Passo 6 – Habilitando o Ntp para iniciar no boot do sistema operacional.

# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

Passo 7 – Aplicando o reboot em ambos os nodes (ba-vm-www-01 e ba-vm-www-02).

# reboot

Passo 8 – Verificando a versão do Docker Engine.

# docker --version
Docker version 1.10.2, build c3959b1

Passo 9 – Verificando a versão do Weave Network.

# weave version
weave script 1.4.5
Unable to find image 'weaveworks/weaveexec:1.4.5' locally
1.4.5: Pulling from weaveworks/weaveexec
ee54741ab35b: Pull complete 
c396d61c0a32: Pull complete 
6f699aeb212d: Pull complete 
499a537fb87d: Pull complete 
6235aa6b611c: Pull complete 
3fb3a546cc1a: Pull complete 
3e46f21eea5d: Pull complete 
9dd33e219371: Pull complete 
b8e5c537a426: Pull complete 
Digest: sha256:0e0ba3023da99dfd7d90528eab350f16325d22e065d45e5a68722060cd174d45
Status: Downloaded newer image for weaveworks/weaveexec:1.4.5
Unable to find weaveworks/weave:1.4.5 image.
weave proxy  1.4.5
Unable to find weaveworks/plugin:1.4.5 image.

Passo 10 – Após a execução do comando weave version, foi feito o download da última versão do Weave Network (repositório weaveworks/weaveexec).

# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
weaveworks/weaveexec   1.4.5               e566e11c8087        19 hours ago        60.64 MB

Passo 11 – Verificando quais containers estão em execução com o comando docker ps.
ba-vm-www-01.

[root@ba-vm-www1 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

ba-vm-www-02.

[root@ba-vm-www2 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Passo 12 – Criando a primeira bridge para o Weave Network.
ba-vm-www-01 – 10.0.1.1/24.

[root@ba-vm-www1 ~]# weave expose 10.0.1.1/24
Unable to find image 'weaveworks/weave:1.4.5' locally
1.4.5: Pulling from weaveworks/weave
3ff04c8da461: Pulling fs layer
b6c842ef1801: Pulling fs layer
3ff04c8da461: Download complete
3ff04c8da461: Pull complete
3ff04c8da461: Pull complete
b6c842ef1801: Verifying Checksum
b6c842ef1801: Download complete
b6c842ef1801: Pull complete
b6c842ef1801: Pull complete
Digest: sha256:82e21f9b4a1ecbd873a921c8724db2f6b5f2fefedefc4c389b1e85f662a30a3b
Status: Downloaded newer image for weaveworks/weave:1.4.5
10.0.1.1

ba-vm-www-02 – 10.0.2.1/24.

[root@ba-vm-www2 ~]# weave expose 10.0.2.1/24
Unable to find image 'weaveworks/weave:1.4.5' locally
1.4.5: Pulling from weaveworks/weave
3ff04c8da461: Pulling fs layer
b6c842ef1801: Pulling fs layer
3ff04c8da461: Download complete
3ff04c8da461: Pull complete
3ff04c8da461: Pull complete
b6c842ef1801: Verifying Checksum
b6c842ef1801: Download complete
b6c842ef1801: Pull complete
b6c842ef1801: Pull complete
Digest: sha256:82e21f9b4a1ecbd873a921c8724db2f6b5f2fefedefc4c389b1e85f662a30a3b
Status: Downloaded newer image for weaveworks/weave:1.4.5
10.0.2.1

Passo 13 – Verificando o status do Weave Network com o comando weave status.
OBS: Perceba que ainda não temos nenhum containers weave iniciado ainda.
ba-vm-www-01.

[root@ba-vm-www1 ~]# weave status

weave container is not present. Have you launched it?

ba-vm-www-02.

[root@ba-vm-www2 ~]# weave status

weave container is not present. Have you launched it?

Passo 14 – Lançando o Weave Network na ba-vm-www-01.
Parâmetros:
–password – Aqui é possível definir uma senha no momento do lançamento dos containers Weave Network.
— nickname – Aqui é possível definir um usuário para os containers Weave Network.

[root@ba-vm-www1 ~]# weave launch --password senha-aqui --nickname weave
Unable to find image 'weaveworks/plugin:1.4.5' locally
1.4.5: Pulling from weaveworks/plugin
ee54741ab35b: Already exists
c396d61c0a32: Already exists
6f699aeb212d: Already exists
499a537fb87d: Already exists
6235aa6b611c: Already exists
3fb3a546cc1a: Already exists
3e46f21eea5d: Already exists
9dd33e219371: Already exists
b8e5c537a426: Already exists
d1bad3b21d48: Pulling fs layer
d1bad3b21d48: Verifying Checksum
d1bad3b21d48: Download complete
d1bad3b21d48: Pull complete
d1bad3b21d48: Pull complete
Digest: sha256:2335171d7ca2b33471567dc13b3994558dc8d28b81422acebbceb52a11cf4d8c
Status: Downloaded newer image for weaveworks/plugin:1.4.5

Passo 15 – Lançando o Weave Network na ba-vm-www-02.

[root@ba-vm-www2 ~]# weave launch --password senha-aqui --nickname weave
Unable to find image 'weaveworks/plugin:1.4.5' locally
1.4.5: Pulling from weaveworks/plugin
ee54741ab35b: Already exists
c396d61c0a32: Already exists
6f699aeb212d: Already exists
499a537fb87d: Already exists
6235aa6b611c: Already exists
3fb3a546cc1a: Already exists
3e46f21eea5d: Already exists
9dd33e219371: Already exists
b8e5c537a426: Already exists
d1bad3b21d48: Pulling fs layer
d1bad3b21d48: Download complete
d1bad3b21d48: Pull complete
d1bad3b21d48: Pull complete
Digest: sha256:2335171d7ca2b33471567dc13b3994558dc8d28b81422acebbceb52a11cf4d8c
Status: Downloaded newer image for weaveworks/plugin:1.4.5

Passo 16 – Verificando o status com o comando weave status no node ba-vm-www-01.

[root@ba-vm-www1 ~]# weave status

        Version: 1.4.5

        Service: router
       Protocol: weave 1..2
           Name: ea:12:5c:ee:00:2c(weave)
     Encryption: enabled
  PeerDiscovery: enabled
        Targets: 0
    Connections: 0
          Peers: 1
 TrustedSubnets: none

        Service: ipam
         Status: idle
          Range: 10.32.0.0-10.47.255.255
  DefaultSubnet: 10.32.0.0/12

        Service: dns
         Domain: weave.local.
       Upstream: 192.168.0.134, 192.168.0.133
            TTL: 1
        Entries: 0

        Service: proxy
        Address: unix:///var/run/weave/weave.sock

        Service: plugin
     DriverName: weave

Passo 17 – Verificando o status com o comando weave status no node ba-vm-www-02.

[root@ba-vm-www2 ~]# weave status

        Version: 1.4.5

        Service: router
       Protocol: weave 1..2
           Name: 12:1c:bd:ab:fe:f4(weave)
     Encryption: enabled
  PeerDiscovery: enabled
        Targets: 0
    Connections: 0
          Peers: 1
 TrustedSubnets: none

        Service: ipam
         Status: idle
          Range: 10.32.0.0-10.47.255.255
  DefaultSubnet: 10.32.0.0/12

        Service: dns
         Domain: weave.local.
       Upstream: 192.168.0.134, 192.168.0.133
            TTL: 1
        Entries: 0

        Service: proxy
        Address: unix:///var/run/weave/weave.sock

        Service: plugin
     DriverName: weave

Passo 18 – Agora é a parte mais bacana do Weave Network. Neste passo será aplicado o comando weave connect. Este comando tem como função unir os nodes ba-vm-www-01 e ba-vm-www-02.

[root@ba-vm-www1 ~]# weave connect 192.168.0.115

Passo 19 – Verificando o status do Weave Network após o comando connect.

# weave status

        Version: 1.4.5

        Service: router
       Protocol: weave 1..2
           Name: ea:12:5c:ee:00:2c(weave)
     Encryption: enabled
  PeerDiscovery: enabled
        Targets: 2
    Connections: 2 (1 established)
          Peers: 2 (with 2 established connections)
 TrustedSubnets: none

        Service: ipam
         Status: idle
          Range: 10.32.0.0-10.47.255.255
  DefaultSubnet: 10.32.0.0/12

        Service: dns
         Domain: weave.local.
       Upstream: 192.168.0.134, 192.168.0.133
            TTL: 1
        Entries: 0

        Service: proxy
        Address: unix:///var/run/weave/weave.sock

        Service: plugin
     DriverName: weave

Passo 20 – Aplicando o weave connect no node ba-vm-www-02.

[root@ba-vm-www2 ~]# weave connect 192.168.0.114

Passo 21 – Verificando o status.

[root@ba-vm-www2 ~]# weave status

        Version: 1.4.5

        Service: router
       Protocol: weave 1..2
           Name: 12:1c:bd:ab:fe:f4(weave)
     Encryption: enabled
  PeerDiscovery: enabled
        Targets: 1
    Connections: 1 (1 established)
          Peers: 2 (with 2 established connections)
 TrustedSubnets: none

        Service: ipam
         Status: idle
          Range: 10.32.0.0-10.47.255.255
  DefaultSubnet: 10.32.0.0/12

        Service: dns
         Domain: weave.local.
       Upstream: 192.168.0.134, 192.168.0.133
            TTL: 1
        Entries: 0

        Service: proxy
        Address: unix:///var/run/weave/weave.sock

        Service: plugin
     DriverName: weave

Passo 22 – Verificando quais containers que foram iniciado pelo Weave Network.
OBS: Perceba que temos 3 (três) containers: weaveplugin – weaveplugin – weave

Estes containers são responsáveis pela administração dos seguintes serviços:
(Switch, Router, Proxy e Plugin).

[root@ba-vm-www1 ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
ac3d4bbb49af        weaveworks/plugin:1.4.5      "/home/weave/plugin"     4 minutes ago       Up 4 minutes                            weaveplugin
9bd7d90220de        weaveworks/weaveexec:1.4.5   "/home/weave/weavepro"   5 minutes ago       Up 5 minutes                            weaveproxy
40aaa5ae04e8        weaveworks/weave:1.4.5       "/home/weave/weaver -"   5 minutes ago       Up 5 minutes                            weave

Passo 23 – Verificando o node ba-vm-www-02.

[root@ba-vm-www2 ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
0326ff933801        weaveworks/plugin:1.4.5      "/home/weave/plugin"     5 minutes ago       Up 5 minutes                            weaveplugin
67e66068a883        weaveworks/weaveexec:1.4.5   "/home/weave/weavepro"   5 minutes ago       Up 5 minutes                            weaveproxy
a62de61c61f7        weaveworks/weave:1.4.5       "/home/weave/weaver -"   5 minutes ago       Up 5 minutes                            weave

Continua no tutorial:
http://tutoriaisgnulinux.com/?p=15735

Fontes:
http://docs.weave.works/
https://www.docker.com/

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

One thought on “>_Cluster CentOS 7.2 – Instalando o Docker Engine e o Weave Network – 1.5

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: