Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.74k stars 1.64k forks source link

[Feature request]: read-only configuration file and separate writable config #21803

Open skandragon opened 5 months ago

skandragon commented 5 months ago

Is your feature request related to a problem? Please describe

It's a problem I have, yes. :)

I want to run zigbee2mqtt in my Kubernetes cluster, using network-based Zigbee gateways. I have this working in Docker on an older PC already, but Kubernetes is where mqtt and most other things live now here at home.

Kubernetes (and best practices) tend to split hard-coded configuration from runtime configuration, and in Kubernetes this is doubly true.

It is more difficult to run zigbee2mqtt in Kubernetes because of this writable configuration file.

Describe the solution you'd like

I'd like some sort of split between configuration.yaml and perhaps runtime-configuration.yaml or something. The idea is, the first file is used to bootstrap the second, or loaded in order so that the runtime will augment the former.

Describe alternatives you've considered

In Kubernetes, a Configmap is a read-only file, and would be a perfect fit for the configuration.yaml file. However, as this is read-only, I cannot use it. A Secret is also a good fit as there are some credentials in the yaml.

What I will likely to is add some sort of script to the zigbee2mqtt startup which will look for a read-only config file, and copy it into the mounted read/write volume on startup, if there is no configuration already in that durable storage.

Additional context

This is also a "gitops" based model, which is common.

kallangerard commented 1 month ago

@skandragon agreed the configuration should be split.

What you could try as a stop gap is using an init container with something like yq to merge your configmap into the configuration.yaml. Just make sure that you don't try to manage any yaml paths that are managed automatically by zigbee2mqtt.

See https://mikefarah.gitbook.io/yq/v/v2.x/merge#updating-files-in-place.

I would use kustomize with a configmap generator with a file input so you can write your static configuration in a real .yaml file, and use an example zigbee2mqtt file to test.