当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- How to deploy Gantt chart quickly and correctly
- QT audio and video development 46 video transmission UDP version
- Introduction to Huawei cloud micro certification examination
- The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
- 大佬们如何在nginx镜像里面增加模块?
- Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
- Stickinengine architecture 12 communication protocol
- In 2020, how can wechat seal numbers be quickly lifted?
- 上海巨微专用蓝牙广播芯片
- Two dimensional code location and alarm system of Expressway
猜你喜欢
迅为-iMX6ULL开发板上配置AP热点
[self taught unity2d legendary game development] map editor
Points to be considered when deleting mapping field of index in ES
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
消防器材RFID固定资产管理系统
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Design of NAND flash interface control
随机推荐
List to map (split the list according to the key, and the value of the same key is a list)
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
How to optimize the decoding performance of dynamsoft barcode reader
Code generator plug-in and creator preform file analysis
Count the number of project code lines
Points to be considered when deleting mapping field of index in ES
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
Novice guidance and event management system in game development
Empty test suite appears in JUnit test
The Interpreter pattern of behavior pattern
2020-09-04: do you understand the function call convention?
Nanjing logo design and production, guide VI system design
关于DevOps的七大误解,99%的人都曾中过招!
ImageMagick - add watermark
STM32F030C6T6兼容替换MM32SPIN05PF
2020 database technology conference helps technology upgrade
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
Zhou Jie: database system of East China Normal University
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
2020-08-19: what mechanism does TCP ensure reliability?