Managing Configuration Patterns
1. Externalized Configuration Pattern
| Source | Use |
|---|---|
| Env Variables | 12-factor; per-deploy overrides |
| Config Files | Mounted ConfigMaps / files |
| Config Server | Spring Cloud Config, etcd, Consul KV |
| Cloud Param Store | SSM Parameter Store, GCP Runtime Config |
| Never | Hardcode env-specific values |
2. Configuration Server Pattern
| Capability | Detail |
|---|---|
| Central Store | Versioned config repo (often git-backed) |
| Environment Profiles | dev / stage / prod overlays |
| Refresh | Push (webhook) or pull (poll) updates |
| Encryption | Encrypt secret values at rest |
| Tools | Spring Cloud Config, Consul, etcd, AWS AppConfig |
3. Service Template Pattern
| Aspect | Detail |
|---|---|
| Definition | Boilerplate / scaffold for new services (build, CI/CD, observability) |
| Tools | Backstage software templates, Cookiecutter, Yeoman |
| Benefits | Consistency, faster onboarding, golden path |
4. Configuration Versioning Pattern
| Practice | Detail |
|---|---|
| Git-Backed | Config in version control; PR review |
| Pinned Versions | Service references config commit/tag |
| Rollback | Revert config without redeploy |
| Audit | Who changed what, when |
5. Feature Toggle Pattern
| Toggle Type | Lifespan |
|---|---|
| Release Toggles | Days/weeks; hide unfinished work in trunk |
| Experiment Toggles | Hours/days; A/B testing |
| Ops Toggles | Long-lived; kill switches |
| Permission Toggles | Permanent; per-user / per-tenant features |
| Tools | LaunchDarkly, Unleash, Flagsmith, ConfigCat |
Example: Feature Flag Use
if (flags.isEnabled("new-checkout-flow", userContext)) {
return newCheckoutService.process(req);
}
return legacyCheckoutService.process(req);
6. Dynamic Configuration Pattern
| Aspect | Detail |
|---|---|
| Definition | Config changes apply without restart |
| Implementation | Watch config source; hot-reload listeners |
| Validation | Validate before applying; rollback on error |
| Use Cases | Log levels, rate limits, feature flags, tunables |
7. Environment-Specific Configuration Pattern
| Approach | Detail |
|---|---|
| Profile-Based | application-{profile}.yaml overlay |
| Per-Env Branches | GitOps with env-specific config |
| Helm Values | Per-env values.yaml |
| Avoid | If/else branching on env in code |
8. Secrets Configuration Pattern
| Pattern | Detail |
|---|---|
| External Vault | Vault, KMS-backed |
| Sidecar Injection | Vault Agent injects to pod filesystem |
| CSI Driver | Mount secrets as files (K8s Secrets Store CSI) |
| Sealed/Encrypted | Sealed Secrets, SOPS for git storage |
9. Configuration Inheritance Pattern
| Layer | Override Order |
|---|---|
| Defaults | Lowest precedence |
| Profile | Per-environment |
| Local File | Per-instance |
| Env Variables | Higher |
| CLI Args | Highest |
10. Configuration Validation Pattern
| When | Detail |
|---|---|
| At Startup | Fail fast if invalid; refuse to start |
| At PR Time | Schema validation in CI |
| At Apply Time | Dry-run before live |
| Schemas | JSON Schema, Spring @ConfigurationProperties + JSR-303 |