简体   繁体   English

python 微服务中的外部化配置

[英]Externalized configurations in python microservices

The Current State:当前 State:

I have some non-negligeble amount of microservices written in python.我用 python 编写了一些不可忽略的微服务。

Each such microservice has its own yaml configuration file that is located in the git repo.每个这样的微服务都有自己的 yaml 配置文件,该文件位于 git 存储库中。 We use dynaconf to read the configuraion.我们使用 dynaconf 来读取配置。

The Problem:问题:

At first it was fine, the configurations were relatively small and it was easy to maintain them.一开始还不错,配置比较小,维护也很方便。 Time went by, and the configurations went larger.时间流逝,配置变得更大。 It became annoying to change the configurations and it is bad that they are scattered between different git repos, ie not centralized.更改配置变得很烦人,而且它们分散在不同的 git 存储库之间很糟糕,即不集中。

I want to use "Externalized Configurations" in order to maintain all the configurations in a single repo and that each microservice will read its portion on startup.我想使用“外部化配置”来维护单个存储库中的所有配置,并且每个微服务将在启动时读取其部分。 I have heard about Spring Boot, but it seems to be way too much and apart from it, it seems that the pip libraries seems to be at beta stage, new and unriliable...我听说过 Spring Boot,但它似乎太多了,除此之外,pip 库似乎处于 beta 阶段,新的和不可靠的......

Is there another reccomendation in this particular use case?在这个特定用例中是否还有其他建议? Or should I proceed with Spring Boot?还是我应该继续使用 Spring 引导?

I think you could create a default config file for each service and use the external storage idea of the dynaconf.我认为您可以为每个服务创建一个默认配置文件,并使用 dynaconf 的外部存储理念。

One possible solution would be to create a simple system to manage these variables with Redis.一种可能的解决方案是使用 Redis 创建一个简单的系统来管理这些变量。

And the DynaConf CLI allows you to make changes on the fly. DynaConf CLI允许您即时进行更改。

You can use Microconfig.IO to manage your configuration with powerful templating and distribution.您可以使用Microconfig.IO通过强大的模板和分发来管理您的配置。 It's language agnostic as long as your configs are YAML or properties format.只要您的配置是 YAML 或属性格式,它就与语言无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM