当前位置:网站首页>9.集群之间服务通信 RoutingMesh
9.集群之间服务通信 RoutingMesh
2020-11-07 16:43:00 【太猪-YJ】
创建overlay网关
docker network create -d overlay demo
docker network ls
NETWORK ID NAME DRIVER SCOPE
7a511becede2 bridge bridge local
im7c34k0bfxh demo overlay swarm
37856c9de79d docker_gwbridge bridge local
c438996bf1e8 host host local
idnr3c47eum5 ingress overlay swarm
a785589db128 lb-scale_default bridge local
14865f2115c6 none null local
e9bba04074f1 wordpress_my-bridge bridge local
创建Service使用network为overlay
如上图所示,我们有三个应用,两个service一个client。它们可能部署在同一个worker node上,也可能分开部署。上图中这三个应用,同时部署在了127.0.0.11这个节点上。client想要访问service应用,可以通过ip+端口号的形式,也可以通过应用名称来访问。是怎么做到的呢?docker engine里有一个DNS服务,它整理了所有应用的名称与IP地址映射关系,但是Docker DNS服务里的生成和存储的IP地址,不是应用所在容器的IP地址,应用都是部署在127.0.0.11节点上的,但是我们看到DNS里存储的ip地址是10.0.3/4/5,这是虚拟IP,VIP。因为部署应用的容器地址因为宕机或者扩容而变化,DNS给应用分配一个虚拟IP,这个虚拟IP是不会变的。这样应用通过虚拟IP互相访问,再通过LVS去实现的。
nslookup www.baidu.com/service name
可以查看域名对应的ip地址,如果域名做了集群部署,是负载均衡的,也会显示多个ip地址。
1.我们在容器中部署应用的时候,需要给应用指定network,network必须是overlay网络协议,这样子swarm的DNS才会使用vip来互相通信。
2.如果部署的应用绑定了接口,即使它部署在某一个节点上,也可以通过访问swarm里的其他节点的此端口号,来访问到应用。
版权声明
本文为[太猪-YJ]所创,转载请带上原文链接,感谢
https://my.oschina.net/xiaoyoung/blog/4706937
边栏推荐
- yum [Errno 256] No more mirrors to try 解决方法
- Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
- 2020-08-20: the difference between go and python?
- JS string - string string object method
- Utility class functions (continuous update)
- Developing STM32 USB with cubemx
- 2020-08-15: under what circumstances should data tasks be optimized?
- Cloudquery v1.2.0 release
- 2020-08-19: what mechanism does TCP ensure reliability?
- August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
猜你喜欢
python3操作gitlab
The method of local search port number occupation in Windows system
2020-08-19: what mechanism does TCP ensure reliability?
#JVM 类加载机制
WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
Git remote library rollback specified version
How to use Gantt chart layers and filters
Detailed software engineering -- the necessary graphs in each stage
2020-09-04: do you understand the function call convention?
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
随机推荐
Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
vue3 新特性
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
August 18, 2020: introduce Mr process?
LEADTOOLS如何检测,读取和写入条形码
How does LeadTools detect, read and write barcodes
Git SSH bad permissions
2020年新规,微信封号怎么快速解除?
如何解决谷歌Chrome浏览器空白页的问题
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
Benefits and functions of auto maintenance app development
The essence of transaction and the principle of deadlock
yum [Errno 256] No more mirrors to try 解决方法
Logo design company, Nanjing
idea 激活到 2089 失效
python3操作Jenkins模块api
python3操作gitlab
Common mathematical basic formulas of recursive and backtracking algorithms
你真的会使用搜索引擎吗?