当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
- Unexpected element.. required element
- The advantages and functions of psychological counseling app
- Message queue - Analysis
- MRAM高速缓存的组成
- DC-1 target
- Google browser realizes video playback acceleration function
- Cloudquery v1.2.0 release
- Configuration of AP hotspot on xunwei-imx6ull development board
- [graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
猜你喜欢
Cloudquery v1.2.0 release
LEADTOOLS如何检测,读取和写入条形码
[doodling the footprints of Internet of things] Introduction to Internet of things
How does LeadTools detect, read and write barcodes
打工人好物——磨炼钢铁意志就要这样高效的电脑
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
Mobile pixel adaptation scheme
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
[forward] how to view UserData in Lua
STM32F030F4P6兼容灵动微MM32F031F4P6
随机推荐
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
心理咨询app开发所具备的优点与功能
Google browser realizes video playback acceleration function
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
How to optimize the decoding performance of dynamsoft barcode reader
What are the highlights of Huawei mate 40 series with HMS?
Hdu3974 assign the task segment tree DFS order
Js字符串-String字符串对象方法
磁存储芯片STT-MRAM的特点
Plug in bilibilibili new version 0.5.5
Empty test suite appears in JUnit test
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)
上海巨微专用蓝牙广播芯片
QT audio and video development 46 video transmission UDP version
Benefits and functions of auto maintenance app development
细数软件工程----各阶段必不可少的那些图
Python 100 cases
Design of NAND flash interface control
Dynamsoft barcode reader v7.5!