mahendra
mahendra

Reputation: 203

dynamic configuration techniques for Microservices

I'm running micro services on Kubernetes cluster, currently all my configurations are injected as environment variables at the time of deployment but few micro services require certain business configuration which can change any number of time over the lifetime of a pod, so I decided to keep them out of ENVs and here is what I could think of,

a configuration server which allows business to modify configs(via UI) and stores configs persistently(some k,v db).

now to update MSs config

So what is the better way to manage the dynamic configuration and update all replicas of required MS only when update happens to a configuration.

Upvotes: 0

Views: 1167

Answers (2)

jdwyah
jdwyah

Reputation: 1282

It's pretty common to build a config service and then have your other services connect to it to pull down config & stream updates.

Examples are Netflix's https://github.com/Netflix/archaius, Amplitude's DynConf https://amplitude.com/blog/dynamic-configuration or Prefab offers it as-a-service https://prefab.cloud/features/config/

These all have different takes on how to solve the problem, but streaming updates over SSE is a good start.

Upvotes: 0

Tomer Paz
Tomer Paz

Reputation: 1

There are several ways to achieve your goal, but the one that seems most applicable in a k8s environment is by using a "CM" cluster service, such as etcd, zookeeper or consul.

This implies code changes to the applications (MSs). for example, they will register to changes in etcd nodes (key-value tree store) specific to each MSs configuration, and be notified once a node has changed, then make a call to retrieve the changes. This kind of design is usually done using a REST or (g)RPC protocols that etcd, zookeeper, consul etc. support. This "observer" pattern I think should answer your concern about expensive polling (also how often does the configuration change anyway? usually a rare event...)

Of course it also implies you will need to maintain a configuration schema for your MSs in that CM store and the application to support dynamic configuration changes.

Upvotes: 0

Related Questions