当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 2020-08-15: under what circumstances should data tasks be optimized?
- Design of NAND flash interface control
- Characteristics of magnetic memory chip STT-MRAM
- 条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
- 1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
- How does LeadTools detect, read and write barcodes
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- Common syntax corresponding table of mongodb and SQL
- 条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
- 测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
猜你喜欢

The advantages and functions of psychological counseling app

2020-08-20: the difference between go and python?

插件Bilibili新版0.5.5

STM32F030K6T6兼容替换灵动MM32F031K6T6
![[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform

2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?

The essence of transaction and the principle of deadlock

The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud

预留电池接口,内置充放电电路及电量计,迅为助力轻松搞定手持应用

Exclusive interview with Alibaba cloud database for 2020 PostgreSQL Asia Conference: Zeng Wenjing
随机推荐
Logo design company, Nanjing
QT audio and video development 46 video transmission UDP version
[elastic search engine]
Google browser realizes video playback acceleration function
【涂鸦物联网足迹】涂鸦云平台全景介绍
Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
Jenkins installation and deployment process
Bluetooth broadcast chip for Shanghai giant micro
2020-08-15: under what circumstances should data tasks be optimized?
Getting started with varhart xgantt
[self taught unity2d legendary game development] map editor
STM32F030C6T6兼容替换MM32SPIN05PF
Common mathematical basic formulas of recursive and backtracking algorithms
Configuration of AP hotspot on xunwei-imx6ull development board
非易失性MRAM存储器应用于各级高速缓存
Event monitoring problem
Characteristics of magnetic memory chip STT-MRAM
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
List to map (split the list according to the key, and the value of the same key is a list)
STM32F030K6T6兼容替换灵动MM32F031K6T6