当前位置:网站首页>confd
confd
2020-11-06 22:33:00 【waynehu】
confd
{{/*
Use lsdir Method , Read ( It can be said that )/services/web A subdirectory under a directory , That is to return to cust1 and cust2 these two items. .
And start a big cycle , The first 1 Secondary cycle ,$dir be equal to cust1 , The first 2 Secondary cycle ,$dir be equal to cust2
*/}}
{{range $dir := lsdir "/services/web"}}
upstream {{base $dir}} {
{{/*
Use printf Method , Compose a string ,%s Some of them use $dir To replace .
The new string after composition is assigned to $custdir, The first time should be "/services/web/cust1/*"
Use gets lookup key by "/services/web/cust1/*" Value , Because it's used *, Multiple values will be found , So we use gets instead of get
Each value goes into a small loop , And use json To analyze ( Note here etcdctl put In the value, Must conform to json Format , Otherwise, parsing will fail here )
Copy the parsed content to $data, Then it can be used
*/}}
{{$custdir := printf "/services/web/%s/*" $dir}}{{range gets $custdir}}
server {{$data := json .Value}}{{$data.IP}}:{{$data.PORT}};
{{end}}
}
server {
server_name {{base $dir}}.example.com;
location / {
proxy_pass {{base $dir}};
}
}
{{end}}
./etcdctl put /services/web/cust1/1 '{"IP": "10.0.0.1","PORT":"81"}'
./etcdctl put /services/web/cust1/2 '{"IP": "10.0.0.2","PORT":"82"}'
./etcdctl put /services/web/cust1/3 '{"IP": "10.0.0.3","PORT":"83"}'
./etcdctl put /services/web/cust2/1 '{"IP": "10.0.0.4","PORT":"84"}'
./etcdctl put /services/web/cust2/2 '{"IP": "10.0.0.5","PORT":"85"}'
./etcdctl put /services/web/cust2/3 '{"IP": "10.0.0.6","PORT":"86"}'
https://github.com/kelseyhightower/confd/blob/master/docs/templates.md
版权声明
本文为[waynehu]所创,转载请带上原文链接,感谢
边栏推荐
- Es create a new index database and copy the old index library, practice pro test effective!
- 2020-08-17: how to solve data skew in detail?
- Code generator plug-in and creator preform file analysis
- How to start the hidden preferences in coda 2 on the terminal?
- 超高频RFID医疗血液管理系统应用
- 【涂鸦物联网足迹】涂鸦云平台全景介绍
- Using JSON webtoken (JWT) to generate token in nodejs
- In 2020, how can wechat seal numbers be quickly lifted?
- [forward] how to view UserData in Lua
- [byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
猜你喜欢

Gantt chart grouping activities tutorial

confd
![[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!

FreeSWITCH视频会议“标准”解决方案

Es create a new index database and copy the old index library, practice pro test effective!

迅为iMX6开发板-设备树内核-menuconfig的使用

2020-08-17: how to solve data skew in detail?

应用层软件开发教父教你如何重构,资深程序员必备专业技能

How to deploy Gantt chart quickly and correctly

List to map (split the list according to the key, and the value of the same key is a list)
随机推荐
STM32F030C6T6兼容替换MM32SPIN05PF
Detect certificate expiration script
Mongo user rights login instruction
Summary of common SQL statements
【涂鸦物联网足迹】涂鸦云平台全景介绍
关于DevOps的七大误解,99%的人都曾中过招!
Using JSON webtoken (JWT) to generate token in nodejs
August 18, 2020: introduce Mr process?
Zhou Jie: database system of East China Normal University
磁存储芯片STT-MRAM的特点
Python 100 cases
图像处理工具包ImagXpress使用教程,如何查看事件
Detailed software engineering -- the necessary graphs in each stage
win7 APPCRASH(解决方法)(转)
VARCHART XGantt入门教程
Event monitoring problem
How to deploy Gantt chart quickly and correctly
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
实验一
Common syntax corresponding table of mongodb and SQL