Beyond .env: structured YAML (AppConfig/YAML) linked into a Kubernetes ConfigMap
Most teams default to flat KEY=VALUE environment variables out of Heroku habit. Once an app has real structure, like an internal phone-line router mapping Twilio numbers, business hours, voicemail greetings, and Slack channels, flat env vars turn unreadable. Here Claude builds a Go service configured via a structured AppConfig/YAML Unit that ConfigHub links into a Kubernetes ConfigMap mounted at /etc/phoneline/phoneline.yaml, hardened with Pod Security Standards (PSS), with an explicit choice between rolling updates (safe default for replicas > 1) and opt-in hot reload (for replicas = 1 or dynamic rules).
Quick start
You need: the ConfigHub plugin (and a local or shared hub for AppConfig/YAML → ConfigMap Unit links). Uses starters/yaml-configmap.yaml.
| By hand | Ask your agent | |
|---|---|---|
| Structure config as YAML | Keep structured routes in phoneline.yaml and link it into a ConfigMap mounted at /etc/phoneline/phoneline.yaml (step 1) | "Configure this service via a structured YAML file mounted at /etc/phoneline/phoneline.yaml rather than flat env vars." |
| Choose rollout lane | Keep ConfigMap hash on the Deployment for replicas > 1 (rolling update), or opt into validated hot-reload + /healthz revision for replicas = 1 (step 3) | "Use ConfigMap-hash rolling updates by default; only enable in-place hot reload if we validate YAML before swapping and expose confighub_revision on /healthz." |
| Address PSS & policy warnings | Remediate PSS securityContext warnings, and annotate deliberate choices like replicas=1 with a reason (step 4) | "Fix the Pod Security Standards warnings, and record an explicit intent annotation explaining why this webhook bot intentionally runs replicas=1." |
| Resolve new image SHA | GitHub Actions pushes image only; RegistryBot updates the image SHA into ConfigHub without semver tag ceremony (step 5) | "Have GitHub Actions build and push the image only; let ConfigHub resolve the new image SHA into the Deployment for review." |
Without ConfigHub: structured config gets crammed into dozens of fragile flat env vars, or a mounted ConfigMap is mutated in place across all replicas simultaneously with zero rollout control and no record of which revision each pod loaded.
Deeper dive
The rest of this page shows the exact AppConfig/YAML → ConfigMap link pattern, rolling updates vs. hot reload trade-offs, intentional policy exception annotations, the no-ceremony image SHA flow, and verification checks.
Show the full walkthrough
Human
What you need
A service reading /etc/phoneline/phoneline.yaml, the ConfigHub plugin, and a local or shared ConfigHub hub (cub CLI).
Steps
- Write structured application settings as YAML (
AppConfig/YAML) instead of flatKEY=VALUEenv vars:mkdir -p ~/phoneline-demo/k8s cat > ~/phoneline-demo/phoneline.yaml <<'EOF' greeting: "Thanks for calling ConfigHub." routes: - number: "+15550100" slack_channel: "#support-voicemail" business_hours: "Mon-Fri 09:00-17:00 UTC" EOF - Mount the linked
ConfigMapas a read-only filesystem volume at/etc/phoneline/phoneline.yamlinside a PSS-hardenedDeployment(runAsNonRoot: true,allowPrivilegeEscalation: false,readOnlyRootFilesystem: true,capabilities.drop: [ALL]):cat > ~/phoneline-demo/k8s/deployment.yaml <<'EOF' apiVersion: apps/v1 kind: Deployment metadata: name: phoneline annotations: confighub.com/policy-intent-replicas: "Single webhook receiver; Twilio retries on restart" spec: replicas: 1 selector: matchLabels: { app: phoneline } template: metadata: labels: { app: phoneline } spec: securityContext: { runAsNonRoot: true } containers: - name: phoneline image: ghcr.io/confighubai/phoneline@sha256:example securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: { drop: [ALL] } volumeMounts: - name: config mountPath: /etc/phoneline readOnly: true volumes: - name: config configMap: { name: phoneline-config } EOF Choose the delivery lane deliberately:
- Safe default (
replicas > 1or crash-capable settings): Upload withcub mini upload --roll-on-configmapso ConfigHub keeps itshash.confighub.com/<configmap>annotation on the pod template and Kubernetes performs a controlled rolling update behind readiness probes (stopping after pod 1 fails instead of crashing every replica simultaneously) with Kubernetes-level revision visibility. - Opt-in hot reload (
replicas = 1or pure dynamic routing rules): Use defaultcub mini upload(which deliberately omits the pod-template ConfigMap hash) only when the app validates YAML before swapping in memory and exposes the loaded revision on/healthz.
test -f ~/phoneline-demo/phoneline.yaml && test -f ~/phoneline-demo/k8s/deployment.yaml- Safe default (
- Store
phoneline.yamlas anAppConfig/YAMLUnit linked to theConfigMapUnit in the same variant, fix PSS trigger warnings, and record intentional exceptions (such asreplicas: 1) with an explicit intent annotation and--change-descreason:grep -q "confighub.com/policy-intent-replicas" ~/phoneline-demo/k8s/deployment.yaml - Keep CI dead simple (the no-ceremony hybrid flow): GitHub Actions builds and pushes the container image only (zero semver tag ceremony and zero GitOps YAML commit loops); RegistryBot picks up the new SHA and ConfigHub auto-resolves it into the
DeploymentUnit ready for staging or owner-approved production release.grep -q "readOnlyRootFilesystem: true" ~/phoneline-demo/k8s/deployment.yaml
Undo it
Delete ~/phoneline-demo. No cluster or external service is modified by the local demo files.
Agent
When building or configuring an app with nested or structured settings:
- Prefer
AppConfig/YAMLmounted at/etc/<app>/<app>.yamlover cramming nested routing rules or lists into flat.envkeys. - Default to ConfigMap-hash rolling updates (
cub mini upload --roll-on-configmap) wheneverreplicas > 1or a bad config could crash pods; only omit--roll-on-configmapfor opt-in hot reload when the app validates YAML before swapping and reports its loaded revision on/healthz. - Remediate PSS and policy warnings cleanly: fix security context issues directly, and for deliberate choices like
replicas=1, ask the person and add an explicit intent annotation +--change-descreason instead of ignoring the warning.
Testing
Configure a PSS-hardened service reading structured YAML from /etc/phoneline/phoneline.yaml with an explicit intent annotation explaining why replicas=1 is deliberate.
This proves: structured AppConfig/YAML linked into a Kubernetes ConfigMap mounted at /etc/<app>/<app>.yaml cleanly scales past flat .env files while keeping rolling-update safety (replicas > 1) vs. opt-in hot-reload (replicas = 1), PSS hardening, and explicit policy-intent annotations clear for both humans and coding agents.