docker - 使用 HAProxy 的 Docker 覆盖
问题描述
我有一个 QA 环境,在其中我在同一个覆盖网络上运行我的所有应用程序和 HAProxy。我希望 HAProxy 能够在服务器不必启动的情况下启动,因此我的服务器配置例如:
backend cirrus
option httpclose
option forwardfor
balance leastconn
server cirrus01 cirrus-bos01:6021 check init-addr none
注意init-addr none
它允许我禁用初始 dns 解析。这种配置的问题是所有服务器都被标记为不健康并且它们永远不会变得健康,所以我总是得到 NOSRV:
2018-12-05T16:50:42+00:00localhost haproxy[12]: 192.168.10.118:64813
[05/Dec/2018:16:50:42.981] main cirrus/<NOSRV>
0/-1/-1/-1/0 503 212 - - SC-- 1/1/0/0/0 0/0
{cirrus.docker-app.qa01.company.com|} "GET / HTTP/1.1"
即使 urlcirrus-bos01
可以从容器本身获得。
现在,如果我check init-addr none
要从服务器定义中删除 , haproxy 会因我尚未部署的服务而崩溃:
[ALERT] 338/165450 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:347] : 'server renderer' : could not resolve address 'ytuploader'.
[ALERT] 338/165450 (1) : Failed to initialize server(s) addr.
因为还没有真正命名的服务器ytuploader
。
是否有 docker/haproxy 解决方案?
解决方案
我找到了解决方案!我将服务器定义从
server cirrus01 cirrus-bos01:6021 check init-addr none
至:
server cirrus01 cirrus-bos01:6021 check init-addr last,libc,none
推荐阅读
- c# - 从另一个列表中过滤 IEnumerable
- javascript - 在winston中更改“消息”键名
- python - Keras LSTM 批处理时间序列输入,提供恒定的精度
- github - 如何使用 Github 让我的开发人员在我的后端工作而无需共享大量凭据和代码?
- javascript - 如何让 Discord Bot 检测表情符号反应并单击(触发)它
- netlogo - 无法指定代理的位置和发芽命令
- typescript - 基于函数参数的动态返回类型
- c++ - 是否可以使用其他目录设置 Atom,例如 Boost 文件?
- multithreading - 使 slurm 使用集群中的所有 cpu 运行脚本
- excel - 将命名表从 Excel 导出到 Access