063、如何使用weave网络(2019-04-03 周三)

 
weave是Weaveworks开发的容器网络解决方案。weave创建的虚拟网络可以将部署在多个host上的容器连接起来。
 
对于容器来说,weave就像一个巨大的以太网交换机,所有容器都被接入这个交换机,容器可以直接通信,无需NAT和端口映射。
 
除此之外,weave的DNS模块使容器可以通过hostname访问
 
实验环境
 
weave不依赖分布式数据库(etcd或者consul)存储交换网络信息。每个主机上只需运行weave组件就能建立起跨host容器网络。
 
#    1、下载安装weave
 
root@host1:~# curl -L git.io/weave -o /usr/local/bin/weave
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100   595    0   595    0     0    213      0 --:--:--  0:00:02 --:--:--  581k
100 52227  100 52227    0     0  11236      0  0:00:04  0:00:04 --:--:-- 58616
root@host1:~# chmod a+x /usr/local/bin/weave
 
#    2、运行weave
 
root@host1:~# weave launch
2.5.1: Pulling from weaveworks/weave
a073c86ecf9e: Pull complete
950f028f729b: Pull complete
d1298aa928c2: Pull complete
1d157c01c74e: Pull complete
c458f7a37ca6: Pull complete
Digest: sha256:a170dd93fa7e678cc37919ffd65601d1015da6c3f10878534ac237381ea0db19
Status: Downloaded newer image for weaveworks/weave:2.5.1
latest: Pulling from weaveworks/weavedb
9b0681f946a1: Pull complete
Digest: sha256:c280cf4e7208f4ca0d2514539e0f476dd12db70beacdc368793b7736de023d8d
Status: Downloaded newer image for weaveworks/weavedb:latest
Unable to find image 'weaveworks/weaveexec:2.5.1' locally
2.5.1: Pulling from weaveworks/weaveexec
a073c86ecf9e: Already exists
950f028f729b: Already exists
d1298aa928c2: Already exists
1d157c01c74e: Already exists
c458f7a37ca6: Already exists
49a09e96fcfc: Pull complete
6d57eb599283: Pull complete
259765bea433: Pull complete
c11f30d06b58: Pull complete
Digest: sha256:ad53aaabf648548ec26cceac3ab49394778322e1623f0d184a2b74ad06338087
Status: Downloaded newer image for weaveworks/weaveexec:2.5.1
7e8598656934a6655d16c34eeb1df238acf76692f7f5f530101ac5c722a78f43
 
#    3、查看weave运行状态,容器和网络
 
root@host1:~# docker ps -a
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
7e8598656934        weaveworks/weave:2.5.1       "/home/weave/weaver …"   27 seconds ago      Up 26 seconds                           weave
65fab63189a6        weaveworks/weaveexec:2.5.1   "data-only"              27 seconds ago      Created                                 weavevolumes-2.5.1
a4d5d7b88819        weaveworks/weavedb:latest    "data-only"              28 seconds ago      Created                                 weavedb
 
root@host1:~# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
59984053007a        bridge              bridge              local
bb03f7574aa2        host                host                local
d60df792c936        mac_net1            macvlan             local
884e50ddfb92        mac_net10           macvlan             local
c402380a197d        mac_net20           macvlan             local
11e39328a6d1        none                null                local
e364db005326        weave               weavemesh           local
root@host1:~# docker network inspect weave
[
    {
        "Name": "weave",
        "Id": "e364db00532678e57f983e286f31ccc10a9fdb152b7b87dafcf48e7675dff3fc",
        "Created": "2019-04-03T08:35:57.945367052+08:00",
        "Scope": "local",
        "Driver": "weavemesh",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "weavemesh",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.32.0.0/12"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {
            "works.weave.multicast": "true"
        },
        "Labels": {}
    }
]
 
 
原文地址:https://www.cnblogs.com/www1707/p/10646611.html