Managing Distributed Configuration

1. Externalizing Configuration

SourceUse
Environment variables12-factor; container-friendly
Config files (mounted)K8s ConfigMap as volume
Config serverCentral HTTP endpoint
Sidecar fetcherPulls + reloads (e.g. consul-template)
Anti-patternHard-coded values, env-specific builds

2. Using Configuration Server

ToolDetail
Spring Cloud ConfigGit-backed, encryption, profiles
HashiCorp Consul KVKV store + watch
etcdWatch + leases
AWS AppConfig / SSMManaged, with deployment strategy
Azure App ConfigurationManaged, label-based

3. Implementing Configuration Refresh

MechanismDetail
PollingPeriodic GET (simple, lag)
Long-poll / watchPush on change (Consul, etcd)
Pub/Sub busSpring Cloud Bus, Kafka
Hot reload@RefreshScope beans
Restart-onlySafer for critical settings

4. Managing Secrets

ToolDetail
HashiCorp VaultDynamic secrets, leases, transit
AWS Secrets Manager / SSMManaged, IAM-controlled
GCP Secret Manager / Azure Key VaultCloud-native
Kubernetes SecretsBase64; combine with KMS / SealedSecrets / SOPS
External Secrets OperatorSync from Vault/SM into K8s
Warning: Never commit plaintext secrets to git. Use SOPS or SealedSecrets for GitOps flows.

5. Using Environment Variables

PracticeDetail
NamingSCREAMING_SNAKE_CASE
PrefixAPP_, service-specific
DefaultsProvide sane defaults in code
ValidationFail-fast on missing required vars
AvoidPutting secrets in env (visible in ps); use mounted files instead when possible

6. Implementing Configuration Profiles

ProfileUse
localDeveloper machine; mocks
devShared dev cluster
stagingProd-like
prodProduction
ActivationSPRING_PROFILES_ACTIVE, env vars

7. Versioning Configuration

ApproachDetail
GitSingle source of truth; PR review
Tag/branch per envPromote by merge
RollbackRevert commit, re-apply
AuditGit log = who/when/what

8. Handling Configuration Hierarchy

Priority (lowest → highest)Source
1Built-in defaults (code)
2Bundled config files
3Profile-specific config
4Config server values
5Environment variables
6Command-line args

9. Implementing Feature Flags

TypeDetail
Release toggleHide unfinished feature
ExperimentA/B test variants
Ops toggleKill switches, throttles
PermissionPer-user/tenant rollout
ToolsLaunchDarkly, Unleash, Flagsmith, OpenFeature

10. Using Configuration Encryption

TechniqueDetail
Envelope encryptionData key encrypted by KMS master key
SOPSEncrypts YAML/JSON keys with age/PGP/KMS
SealedSecretsBitnami; encrypted with cluster key
Spring Cloud Config{cipher}... values

11. Managing Configuration Schema

ConcernPractice
Typed config@ConfigurationProperties classes
Schema validationJSON Schema, viper, koanf
DocumentationGenerate from typed config
MigrationVersioned schema; backward compatible

12. Using Configuration Management Tools

ToolUse Case
AnsiblePush config to VMs
Helm / KustomizeK8s manifest templating
Argo CD / FluxGitOps continuous reconciliation
TerraformCloud resource config (paramstore, secrets)
CrossplaneK8s-native cloud config