Search code examples
kubernetesmicroservicesconfigmap

K8s configmap for application dynamic configuration


I have a microservice for handling retention policy. This application has default configuration for retention, e.g.: size for retention, files location etc. But we also want create an API for the user to change this configuration with customized values on runtime.

I created a configmap with the default values, and in the application I used k8s client library to get/update/watch the configmap.

My question is, is it correct to use configmap for dynamic buisness configuration? or is it meant for static configuration that user is not supposed to touch during runtime?

Thanks in advance


Solution

  • There are no rules against it. A lot of software leverages kube API to do some kind of logic / state, ie. leader election. All of those require the app to apply changes to a kube resource. With that in mind do remember it always puts some additional load on your API and if you're unlucky that might become an issue. About two years ago we've been experiencing API limits exhaustion on one of the managed k8s services cause we were using a lot of deployments that had rather intensive leader election logic (2 requests per pod every 5 sec). The issue is long gone since then, but it shows what you have to take into account when designing interactions like this (retries, backoffs etc.)