Although in an ideal world of Kubernetes you don't need to care about dependencies, the reality is different; we do have applications (consumer services) that rely on backing services (e.g. databases) to be available at startup.
To achieve this deployment order for services we have a few options available with k8s:
- check the backing service readiness in an init container
- check the backing service readiness in the readiness probe
- check the backing service readiness in the application itself
Now, the backing services do own some configuration properties that are required by the consumer services as well e.g. the k8s service name, credentials, ports etc.
The usual approach I encountered is that these configuration properties are hardcoded into the initContainer/readinessProbe implementation for the consumer service. I think this is suboptimal as you have to manually keep the backing service and consumer service configuration in sync, duplicate the configuration in both services and manually reconfigure the consumer service when the backing service updates its config.
What are some best practices/patterns to keep the consumer service in sync with a backing service configuration changes?
Is it a good practice to rely on operators for backing service deployment and inject secrets/configmaps as requested by the consumer service through CRs?
Thanks!