Managing Distributed Configuration
1. Implementing Externalized Configuration
| Source | Detail |
|---|---|
| Env vars | 12-factor; container-friendly |
| ConfigMaps | K8s native |
| Config server | Spring Cloud Config, Consul |
| Secrets store | For sensitive values |
2. Implementing Configuration Hierarchy
| Order (lowest → highest precedence) | Detail |
|---|---|
| 1 | Built-in defaults |
| 2 | Profile / env file |
| 3 | Config server |
| 4 | Env vars |
| 5 | CLI args |
3. Implementing Dynamic Configuration Updates
| Mechanism | Detail |
|---|---|
| Long-poll / watch | Consul watch, etcd watch, ZK watch |
| Push (SSE / gRPC) | Apollo Config, Nacos |
| Spring Cloud Bus | Refresh via message bus |
| Atomic apply | Validate before swap |
4. Implementing Configuration Versioning
| Practice | Detail |
|---|---|
| Git-backed | All changes tracked, reviewable |
| Immutable versions | Tag/commit hash addresses config |
| Per-env branches/folders | dev, staging, prod |
5. Implementing Configuration Validation
| Stage | Detail |
|---|---|
| Schema (JSON Schema) | Pre-commit / CI |
| Type-safe binding | @ConfigurationProperties (Spring), Viper (Go) |
| Startup check | Fail-fast on invalid required values |
| Dry-run apply | Validate against staging first |
6. Using Configuration Servers
| Server | Notes |
|---|---|
| Spring Cloud Config | Git-backed, env-aware |
| Consul KV | Watch + ACL |
| etcd | K8s, strongly consistent |
| ZooKeeper | Legacy, mature |
| Apollo / Nacos | Push-based, multi-env UI |
| AWS AppConfig | Managed; deployment strategies |
7. Implementing Feature Toggles
| Type | Lifetime | Use |
|---|---|---|
| Release toggle | Days | Hide WIP feature |
| Experiment toggle | Weeks | A/B testing |
| Ops toggle | Long | Kill switch, throttle |
| Permission toggle | Long | Per-user/tenant |
| Tools | — | LaunchDarkly, Unleash, OpenFeature, ConfigCat |
8. Handling Configuration Secrets
| Practice | Detail |
|---|---|
| Never in git plain | Use SOPS, sealed-secrets |
| Inject at runtime | Vault Agent, CSI Secrets Driver |
| Auto-rotate | Dynamic DB creds (Vault) |
| Avoid env vars for sensitive | Use mounted files (no proc env exposure) |
9. Implementing Configuration Rollback
| Approach | Detail |
|---|---|
| Git revert | One commit back, redeploy |
| Versioned KV | etcd revisions, Consul history |
| Deployment strategy | AppConfig staged rollout w/ alarms |
| Auto-rollback | Trigger on metric breach |
10. Understanding Configuration as Code
| Tool | Domain |
|---|---|
| Terraform / OpenTofu | Cloud infra |
| Pulumi | Real-language IaC |
| Helm / Kustomize | K8s manifests |
| Ansible | OS-level |
| Crossplane | K8s-native cloud provisioning |