Stay Hungry,Stay Foolish!

confd+etcd+nginx 服务发现

 confd+etcd+nginx 服务发现

https://learnku.com/articles/36229

 

 https://www.chenshaowen.com/blog/service-discovery-etcd-confd-nginx.html

在进行应用部署时,服务运行起来后,通过接口向 Etcd 注册相关 key-value 信息,Confd 检测到 Etcd 的 key-value 变化后,立即触发程序通过模板形成新的 Nginx 配置文件。

Nginx 先做离线语法测试,如果没问题就覆盖原配置,进而 reload,测试不通过就不覆盖原配置,整个过程安全可控。

 

 

https://github.com/fanqingsong/docker-compose_confd_etcd_nginx

confd - docker-compose - etcd - nginx

Abstract

This practice follows confd - Quickstart Guide - Advanced Example.

docker-compose manages the following services:

  • etcd-server: key-value store, backend for confd
  • confd-nginx: nginx server managed by confd acording to the values inserted to etcd-server. Requests to localhost are routed to the python app
  • etcd-curl: inserts values to etcd-server via curl
  • py-app: simple python flask server, target of nginx proxy

etcd

https://etcd.io/

A distributed, reliable key-value store for the most critical data of a distributed system

What is etcd?

etcd is a strongly consistent, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node. Learn more

https://learn.lianglianglee.com/%e4%b8%93%e6%a0%8f/etcd%e5%ae%9e%e6%88%98%e8%af%be/08%20Watch%ef%bc%9a%e5%a6%82%e4%bd%95%e9%ab%98%e6%95%88%e8%8e%b7%e5%8f%96%e6%95%b0%e6%8d%ae%e5%8f%98%e5%8c%96%e9%80%9a%e7%9f%a5%ef%bc%9f.md

第一,client获取事件的机制,etcd是使用轮询模式还是推送模式呢?两者各有什么优缺点?

第二,事件是如何存储的? 会保留多久?watch命令中的版本号具有什么作用?

第三,当client和server端出现短暂网络波动等异常因素后,导致事件堆积时,server端会丢弃事件吗?若你监听的历史版本号server端不存在了,你的代码该如何处理?

第四,如果你创建了上万个watcher监听key变化,当server端收到一个写请求后,etcd是如何根据变化的key快速找到监听它的watcher呢?

接下来我就和你分别详细聊聊etcd Watch特性是如何解决这四大问题的。搞懂这四个问题,你就明白etcd甚至各类分布式存储Watch特性的核心实现原理了。

轮询 vs 流式推送

confd

https://github.com/kelseyhightower/confd

confd is a lightweight configuration management tool focused on:

https://ops-doc.readthedocs.io/zh/latest/Linux_Notes/tools/confd-usage.html

使用来自 etcd 或 consul 的模板和数据管理本地应用程序配置文件。

confd是一个轻量级的配置管理工具,专注于:

https://zhuanlan.zhihu.com/p/99414682

confd用来动态更新配置文件,架构如下:

confd作用流程:

 

https://www.cnblogs.com/Anker/p/6112022.html

 

 

posted @ 2024-07-13 12:49  lightsong  阅读(1)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel