I have a consul server running on https://dev.example.com/ on which I store configurations as below:
consul key name = dev
consul key value = some yaml data
kubernetes configMap value some yaml data
--> ( this is in sync with consul data )
what I want to do is as soon as I change something in some yaml data
, the values should be automatically reflected in configMap and pod should be reloaded automatically to capture new values.
I have tried envconsul
but it only picks keys with one value.
I tried consul-template
but did not find any good working example.
Take a look at https://github.com/Trendyol/trendyol-consul-template-injector. It allows you to inject consul-template as a sidecar to your pod, and will generate files from templates that are provided in a ConfigMap. Your application will need to monitor this generated file, and reload itself when the file changes.
See https://medium.com/trendyol-tech/configuration-and-secret-management-with-consul-template-on-kubernetes-dcc4c6695142 for a more detailed blog post explaining why this was built and how it works.