All academies
Roadmap
Level 14Cloud-Native Operations 25 min

Configuration Management

Externalized config, the Twelve-Factor approach, config servers, feature flags, and secrets.

Config is not code

The Twelve-Factor App methodology (factor III) demands strict separation of config from code: anything that varies between environments — URLs, credentials, limits, flags — lives outside the artifact. One immutable build is promoted through dev, staging, and production; only its environment changes.

The configuration hierarchy

In practice config arrives in layers, each overriding the last:

  • Sane defaults baked into the app
  • Environment-specific files (ConfigMaps in Kubernetes)
  • Environment variables injected at deploy
  • Centralized config service (Spring Cloud Config, Consul KV) for runtime changes
  • Feature flags for per-user/percentage rollouts

Secrets are special

Credentials, API keys, and certificates must never live in git or plain ConfigMaps. Use a secrets manager (Vault, AWS Secrets Manager, sealed-secrets) with encryption at rest, access audit, and rotation. In Kubernetes, mount Secrets as files or env vars — and restrict who can read them via RBAC.

K8s ConfigMap + Secret consumption
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: order-service
          envFrom:
            - configMapRef: { name: order-config }   # non-sensitive
          env:
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef: { name: order-db, key: password }

Dynamic config and feature flags

Some changes shouldn't require a redeploy: log levels during an incident, rate limits under attack, or gradually enabling a new checkout flow. Config servers with refresh endpoints and feature-flag systems (LaunchDarkly, Unleash) enable runtime changes — with the discipline that every flag has an owner and an expiry date, or you accumulate a combinatorial testing nightmare.

Key takeaways

  • Build once, promote everywhere — config varies by environment, the artifact never does.
  • Layer config: defaults → files/ConfigMaps → env vars → config service → flags.
  • Secrets need dedicated tooling: encryption, audit, rotation — never git.
  • Feature flags enable progressive delivery but need owners and expiry dates.

Knowledge check

Q1Multiple choice

Per Twelve-Factor, why must config live outside the build artifact?

Q2Scenario

During an incident you need debug logs on one service immediately. What capability makes this possible without a redeploy?

Q3Multiple choice

Where should a production database password live?

Answer all questions to submit