.env: structured YAML (AppConfig/YAML) linked into a Kubernetes ConfigMapFlat KEY=VALUE environment variables break down as soon as a service has nested rules—like an on-call alert router mapping severities, business hours, escalation timeouts, and Slack channels. In this walkthrough, a Go service reads structured YAML (AppConfig/YAML) from /etc/oncall-router/oncall-router.yaml, linked by ConfigHub (Local Hub or Cloud Hub) into a read-only Kubernetes ConfigMap, with a clear choice between rolling updates (replicas > 1) and opt-in hot reload (replicas = 1).
You need: the ConfigHub plugin (Zero Hub) plus a Local Hub (cub local start) or Cloud Hub for AppConfig/YAML → ConfigMap links. Uses starters/yaml-configmap.yaml. (cub repo upload remains a silent compatibility alias for cub repo upload.)
| By hand | Ask your agent | |
|---|---|---|
| Store config as YAML | Keep structured routes in oncall-router.yaml and mount a linked ConfigMap at /etc/oncall-router/oncall-router.yaml (step 1) | "Configure this service via a structured YAML file mounted at /etc/oncall-router/oncall-router.yaml instead of flat env vars." |
| Pick rollout mode | Use cub repo upload --roll-on-configmap for replicas > 1, or opt into validated hot reload + /healthz revision for replicas = 1 (step 3) | "Use ConfigMap-hash rolling updates by default; only allow in-place hot reload if the app validates YAML before swapping." |
| Record policy choices | Fix Pod Security Standards warnings and annotate deliberate exceptions like replicas=1 (step 4) | "Fix the Pod Security Standards warnings and record an intent annotation explaining why this service runs replicas=1." |
| Update image SHA | CI pushes the image; ConfigHub updates the Deployment image SHA for review (step 5) | "Have CI build and push the image only; let ConfigHub resolve the new SHA into the Deployment for review." |
Without ConfigHub: nested settings get stuffed into fragile env vars, or a ConfigMap is edited in place across every replica with no rollout control or revision history.
A service reading /etc/oncall-router/oncall-router.yaml, the ConfigHub plugin (Zero Hub), and a Local Hub (cub local start) or Cloud Hub (cub CLI).
AppConfig/YAML) instead of flat env vars:
mkdir -p ~/oncall-router-demo/k8s
cat > ~/oncall-router-demo/oncall-router.yaml <<'EOF'
default_channel: "#ops-triage"
routes:
- severity: "sev1"
slack_channel: "#oncall-urgent"
business_hours: "Mon-Fri 09:00-17:00 UTC"
escalation_minutes: 15
EOFConfigMap read-only at /etc/oncall-router/oncall-router.yaml in a hardened Deployment:
cat > ~/oncall-router-demo/k8s/deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: oncall-router
annotations:
confighub.com/policy-intent-replicas: "Single webhook receiver; alert source retries on restart"
spec:
replicas: 1
selector:
matchLabels: { app: oncall-router }
template:
metadata:
labels: { app: oncall-router }
spec:
securityContext: { runAsNonRoot: true }
containers:
- name: oncall-router
image: ghcr.io/acme/oncall-router@sha256:example
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: { drop: [ALL] }
volumeMounts:
- name: config
mountPath: /etc/oncall-router
readOnly: true
volumes:
- name: config
configMap: { name: oncall-router-config }
EOFChoose the rollout mode:
replicas > 1): Run cub repo upload --roll-on-configmap so Kubernetes performs a rolling update behind readiness probes instead of changing every pod at once.replicas = 1): Use default cub repo upload only when the app validates YAML before swapping in memory and reports its loaded revision on /healthz.volumes[].image): Because mutating a ConfigMap in place in etcd still skews autoscaled pods and hits etcd's 1 MiB cap, the same binary can scale unchanged from local YAML → ConfigMap → a digest-pinned OCI Config Bundle in Story 31.test -f ~/oncall-router-demo/oncall-router.yaml && test -f ~/oncall-router-demo/k8s/deployment.yamloncall-router.yaml as an AppConfig/YAML Unit linked to the ConfigMap Unit, fix security warnings, and document deliberate overrides like replicas: 1:
grep -q "confighub.com/policy-intent-replicas" ~/oncall-router-demo/k8s/deployment.yamlDeployment Unit for review.
grep -q "readOnlyRootFilesystem: true" ~/oncall-router-demo/k8s/deployment.yamlDelete ~/oncall-router-demo. No cluster or external service is changed.
When configuring a service with nested settings:
/etc/<app>/<app>.yaml over flat .env keys, with --print-default-config and side-effect-free --validate-config.cub repo upload --roll-on-configmap whenever replicas > 1 or a bad setting can crash pods.replicas=1, ask first and record an intent annotation with --change-desc.Configure a hardened service reading structured YAML from /etc/oncall-router/oncall-router.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 scales cleanly beyond flat .env files while keeping rolling updates, security defaults, and policy reasons explicit.