使用Nginx,Consul-template和Docker获取商店密钥前缀错误的Consul模板

时间:2017-01-17 20:25:10

标签: nginx docker consul consul-template

Nginx和consul模板的新手,但我认为除了日志中的错误之外,我收到很多噪音(每15-30秒发出100条左右的错误消息),我才能正常工作。看起来它是consul-template错误,它可以连接/获取数据......但它确实获取数据并正确构建模板。所以,不确定问题是什么。

如何修复错误?或者如果它们是预期的,我怎么能不将它们记录到stdout / stderr,这会使我的nginx日志记录变得混乱。

谢谢, 丹

错误(为各种APP反复收到这些消息):

2017/01/17 20:07:35 [ERR] (view) "storeKeyPrefix(services/prod/SOMEAPP/SOMEKEY)" store key prefix: error fetching: Get http://consul.example.com:8500/v1/kv/services/prod/SOMEAPP/SOMEKEY/?index=13120537&recurse=&stale=&wait=60000ms: EOF
2017/01/17 20:07:35 [ERR] (runner) watcher reported error: store key prefix: error fetching: Get http://consul.example.com:8500/v1/kv/services/prod/SOMEAPP/SOMEKEY/?index=13120537&recurse=&stale=&wait=60000ms: EOF

Nginx dockerfile

FROM nginx:1.11.8

RUN rm /etc/nginx/conf.d/default.conf
COPY html /usr/share/nginx/html
COPY conf /etc/nginx

RUN DEBIAN_FRONTEND=noninteractive \
    apt-get update -qq && \
    apt-get -y install curl runit unzip && \
    rm -rf /var/lib/apt/lists/*

ENV CT_URL https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_amd64.zip
RUN curl -o consul-template.zip $CT_URL && \
 unzip consul-template.zip && \
 chmod a+x consul-template && \
 mv consul-template /usr/bin/consul-template

ADD services/nginx.service /etc/service/nginx/run
RUN chmod a+x /etc/service/nginx/run
ADD services/consul-template.service /etc/service/consul-template/run
RUN chmod a+x /etc/service/consul-template/run

ADD templates/nginx-http-upstream.conf /etc/consul-templates/nginx-http.conf
ADD templates/nginx-tcp-upstream.conf /etc/consul-templates/nginx-tcp.conf

RUN touch /etc/nginx/conf.d/http.conf
RUN touch /etc/nginx/conf.d/tcp.conf

EXPOSE 80
EXPOSE 443

CMD ["/usr/bin/runsvdir", "/etc/service"]

服务/ nginx.service

#!/bin/sh

/usr/sbin/nginx -c /etc/nginx/nginx.conf -t && \
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"

服务/领事template.service

#!/bin/sh

exec consul-template \
    -consul=$CONSUL_HOST:$CONSUL_PORT \
    -log-level=warn \
    -template "/etc/consul-templates/nginx-http.conf:/etc/nginx/conf.d/http.conf:sv hup nginx"\
    -template "/etc/consul-templates/nginx-tcp.conf:/etc/nginx/conf.d/tcp.conf:sv hup nginx"

0 个答案:

没有答案