我有多个微服务运行在我的AWS ECS Fargate集群上。在一个任务(pod)中,将有多个容器(一个用于核心业务服务的容器和另外三个侧容器)。以下是这些集装箱的清单:
核心业务服务容器(在特定的port)
。
所有这些集装箱都已投入使用,运行良好。问题是重新加载haproxy。由于领事模板负责更新haproxy.cfg文件,我是否需要在领事模板本身上添加一些配置来更新haproxy?
以下是我当前用于领事模板的命令:
consul-template -consul-addr=xx.xx.xx.xx:8500 -template /etc/consul-template/data/haproxy.cfg.ctmpl:/etc/consul-template/data/haproxy.cfg我怎样才能做到这一点呢?
发布于 2021-06-17 12:12:12
我目前有完全相同的问题,但对Nginx。
从我的研究来看,没有很好的解决办法。似乎起作用的是装入卷。
-v /var/run/docker.sock:/var/run/docker.sock在领事-模板容器上。
我看到你在用:
consul-template -consul-addr=xx.xx.xx.xx:8500 -template /etc/consul-template/data/haproxy.cfg.ctmpl:/etc/consul-template/data/haproxy.cfg为了在领事-模板呈现新的配置文件后运行命令,请使用如下所示:
consul-template -consul-addr=xx.xx.xx.xx:8500 -template /etc/consul-template/data/haproxy.cfg.ctmpl:/etc/consul-template/data/haproxy.cfg:docker run haproxy-container command-to-reload-haproxy提示
我发现使用领事-模板配置文件更具可读性,语言在这里有很好的说明:https://github.com/hashicorp/consul-template/blob/master/docs/configuration.md。
使用这种方法,您将有一个用于领事模板的配置文件(例如consul_template_config.hcl),如下所示:
consul {
address = "consul-address:8500"
}
template {
source = "/etc/consul-template/data/haproxy.cfg.ctmpl"
destination = "/etc/consul-template/data/haproxy.cfg"
command = "docker run haproxy-container command-to-reload-haproxy"
}然后,使用以下方法运行领事-模板容器
consul-template -config /path/to/consul_template_config.hcl或使用
consul-template -config /path/to/folder/containing->consul_template_config.hcl (This approach is more advanced, and lets you have consul-template-configs across multiple files, and not only in 1 like consul_template_config.hcl)我知道这不是一个很好的解决方案使用这个码头卷(安全警告),但这是我可以找到关于我们的用例。
https://stackoverflow.com/questions/67469120
复制相似问题