2018-06-07 consul + consul-template 界面修改配置文件(单文件无需模板)

supervisor 配置文件,指定consul-template 配置文件路径:

[program:consul_template]
command=/md0/consul_template/consul-template -config /md0/consul_template/config.json 
directory=/md0/consul_template/
user=root
autorestart = true
redirect_stderr = true
stdout_logfile = /var/log/consul_template.log
stderr_logfile = /var/log/consul_template_error.log

consul-template 版本:

./consul-template -v
consul-template v0.19.4 (68b1da2)

cat config.json 指定模板为consul界面内容,指定目标文件为/md0/prometheus-2.2.1.linux-amd64/prometheus.yml, 并指定代理服务器地址

consul {
  address = "127.0.0.1:8500"
  ssl {
    enabled = false
    verify = false
  }
}

pid_file = "/var/run/consul-template.pid"
log_level = "DEBUG"

template {   
source = "./prometheus.ctmpl"  
destination = "/md0/prometheus-2.2.1.linux-amd64/prometheus.yml"  
command = "curl -X POST http://localhost:9090/-/reload"  
}

关联 consul kv 界面内容:

{{key "prometheus"}}

你可能感兴趣的:(2018-06-07 consul + consul-template 界面修改配置文件(单文件无需模板))