当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 心理咨询app开发所具备的优点与功能
- The essence of transaction and the principle of deadlock
- Erd-online free online database modeling tool
- Application of UHF RFID medical blood management system
- STM32F030C6T6兼容替换MM32SPIN05PF
- Application insights application insights use application maps to build request link views
- A concise tutorial for Nacos, ribbon and feign
- 2020-09-04: do you understand the function call convention?
- 10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
- August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
猜你喜欢

如何使用甘特图图层和筛选器

ImageMagick - 添加水印

Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment

Detailed software engineering -- the necessary graphs in each stage

实验一

Introduction to the development of small game cloud

RFID fixed assets management system for fire equipment

Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)

The advantages and functions of psychological counseling app

How to deploy Gantt chart quickly and correctly
随机推荐
Unexpected element.. required element
Hdu3974 assign the task segment tree DFS order
应用层软件开发教父教你如何重构,资深程序员必备专业技能
Method of code refactoring -- Analysis of method refactoring
Points to be considered when deleting mapping field of index in ES
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
[self taught unity2d legendary game development] map editor
The isolation level of transaction and its problems
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
Application insights application insights use application maps to build request link views
打工人好物——磨炼钢铁意志就要这样高效的电脑
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
JVM class loading mechanism
image operating system windows cannot be used on this platform
Jenkins installation and deployment process
Exclusive interview with Alibaba cloud database for 2020 PostgreSQL Asia Conference: Zeng Wenjing
In 2020, how can wechat seal numbers be quickly lifted?
August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
MRAM高速缓存的组成
[learning] interface test case writing and testing concerns