当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Utility class functions (continuous update)
- 细数软件工程----各阶段必不可少的那些图
- Stickinengine architecture 12 communication protocol
- How to use Gantt chart layers and filters
- Introduction to the development of small game cloud
- 轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
- How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
- August 14, 2020: what are the execution engines for data tasks?
- LEADTOOLS如何检测,读取和写入条形码
- Hdu3974 assign the task segment tree DFS order
猜你喜欢
Common syntax corresponding table of mongodb and SQL
Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
如何使用甘特图图层和筛选器
The essence of transaction and the principle of deadlock
南京标识标牌设计制作,导视VI系统设计
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
Gantt chart grouping activities tutorial
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
Two dimensional code location and alarm system of Expressway
随机推荐
上海巨微专用蓝牙广播芯片
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
Mongo user rights login instruction
Interviewer: how about shardingsphere
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
VARCHART XGantt入门教程
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
How to add modules to nginx image?
如何才能快速正确的部署甘特图
Nanjing logo design and production, guide VI system design
磁存储芯片STT-MRAM的特点
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
迅为-iMX6ULL开发板上配置AP热点
【涂鸦物联网足迹】物联网基础介绍篇
[self taught unity2d legendary game development] map editor
confd
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.