matrix-org / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://matrix-org.github.io/dendrite/
Apache License 2.0
5.75k stars 675 forks source link

Configuration by Environment Variables #2591

Open genofire opened 2 years ago

genofire commented 2 years ago

Problem:

In a K8s it is really common to run dependencies by other applications like an database operator (zalando's postgres operator). Which generates k8s secrets, for credentials like username and password.

It would be nice to use them directly (instatt of generate configfiles, stored in new k8s secrets with helm or other tooling). Therefore exists the possibility to use envFromSecrets in k8s deployments.

Description/Solution:

So please make it possible to give dendrite configuration parameters with env variables.

Implemented Suggested:

Maybe you like to use the golang library viper and cobra from spf13 for it.

neilalexander commented 2 years ago

Previously discussed in #1958, #393.

genofire commented 2 years ago

Oh sorry, have not looked after closed/rejected issues :(

Sad, will you accept MRs with Viper? If somebody else dies it?

neilalexander commented 2 years ago

The conclusion we've come to in the past is that we might end up doing this in the future, but we probably won't do it now. This increases the configuration surface area considerably and the configuration format isn't completely stable yet anyway, so it's easier for us to deal with one thing for now: the configuration file.

genofire commented 2 years ago

In best, only structure should be used for everything and env-variables names should be generetes (like the yaml from the same struct)

The question is, are you willing to merge a PR, if it make nothing change for the way of yaml-file structure and internel config struct ... just the parsing of env variables also.

genofire commented 2 years ago

@neilalexander i started to implement a solution. if i finish it would you merge?

Any suggestion / tips for easier review later?

kegsay commented 1 year ago

We intend to officially support k8s/Helm environments in the future. This means we will be heading in the direction of configuration with env vars, but we aren't there yet. The aforementioned concerns remain valid:

This increases the configuration surface area considerably and the configuration format isn't completely stable yet anyway, so it's easier for us to deal with one thing for now: the configuration file.

Especially with our team smaller than before, we cannot devote time to extending the configuration surface area at this time unfortunately.

reddec commented 1 year ago

What do you think about piping a raw yaml config content over something like envsubst in go. @kegsay

genofire commented 1 year ago

thats what the koanf PR hase done ...