Video in progress
Configuration lives in several places: application.yml, a ConfigMap, Config Server, a feature flag system, a secret store. How do you decide what belongs where?
By how fast it changes and who changes it: what changes with the code lives in the repo; what depends on the environment is in the deploy manifest; what must change quickly without a deploy is in the feature flag system; and anything secret is only in the secret store.
📖 Answer
The problem usually looks like this: during an incident a timeout has to be changed, but nobody knows where the value comes from: the yml, an env var, or Config Server. Spring's property precedence order adds more confusion on top.
I agree a table like this with the teams:
| Type | Example | Where | Changes via |
|---|---|---|---|
| Code-related defaults | pool size, retry count | application.yml |
a code release |
| Environment-specific | DB URL, external API address | Helm values / ConfigMap | a deploy |
| Operational "levers" | rate limit, kill switch | feature flag system | seconds, with audit |
| Secret | passwords, tokens | Vault / cloud secret manager | rotation |
The rules:
- one value, one source. If a key is in both the yml and a ConfigMap, review rejects it;
- everything that changes without a deploy must have an audit trail: who, when, why. Git-backed configuration in Config Server gives you this, a manual
kubectl edit configmapdoes not; - dynamic configuration is dangerous: a wrong value reaches every pod instantly. So even in the flag system there should be gradual enabling and validation;
- the app should validate its configuration at startup (
@Validated@ConfigurationProperties). It is better not to come up than to come up with a bad value.
Spring Cloud Config Server is central, but it also becomes a critical dependency: if it is down, new pods do not come up. On Kubernetes many companies have dropped it and moved to ConfigMap + GitOps + a separate flag system. The choice depends on the team's current infrastructure.
Sign up to mark studied questions and save your progress.