Editing a Kubernetes ConfigMap in place in etcd creates silent fleet drift: any newly autoscaled or restarted pod boots immediately with the new config while existing pods keep running the old one, and etcd caps ConfigMaps at 1 MiB. When an app follows three simple rules (New 12-Factor: read YAML from --config /etc/<app>/<app>.yaml, print defaults via --print-default-config, and validate without side effects via --validate-config), cub bundle build (Zero Hub — no hub or cluster required) validates every file, blocks leaked secrets, and packs an immutable sha256-pinned OCI bundle for Kubernetes 1.36+ volumes[].image.
You need: the ConfigHub plugin (Zero Hub) and a service implementing --config, --print-default-config, and --validate-config (20-line Go example below). (cub bundle ... remains a silent compatibility alias.)
| By hand | Ask your agent | |
|---|---|---|
| Wire validator hook | cub bundle init --dir config --mount /etc/oncall-router --validate-cmd "go run ./main.go --validate-config --config config/oncall-router.yaml" (step 2) | "Create .confighub-bundle.yaml for /etc/oncall-router so every edit runs --validate-config automatically." |
| Validate before packaging | cub bundle validate (step 3) | "Validate the YAML with --validate-config and reject any leaked secrets." |
| Build immutable OCI bundle | cub bundle build --out dist/oncall-router-bundle.oci · cub bundle inspect dist/oncall-router-bundle.oci (step 4) | "Build a deterministic OCI bundle from config/ and print its sha256: digest." |
| Generate K8s 1.36+ PodSpec | cub bundle podspec --app oncall-router --ref ghcr.io/acme/oncall-router-config@sha256:... --mount /etc/oncall-router (step 5) | "Generate a hardened Kubernetes 1.36+ volumes[].image PodSpec mounting this OCI bundle read-only at /etc/oncall-router." |
Without ConfigHub: editing a ConfigMap in place drifts autoscaled pods mid-rollout, bad config shows up only after containers crash-loop, and custom OCI build scripts break digest reproducibility.
The ConfigHub plugin (Zero Hub) and Go 1.22+ (or any binary with --config, --print-default-config, and --validate-config). No hub, Kubernetes cluster, or registry login is required to build and inspect the local OCI bundle.
oncall-router) that reads structured YAML from --config /etc/oncall-router/oncall-router.yaml, prints defaults via --print-default-config, and checks config via --validate-config:
mkdir -p ~/oci-bundle-demo/config && cd ~/oci-bundle-demo
cat > main.go <<'EOF'
package main
import (
"flag"
"fmt"
"os"
"strings"
)
const defaultYAML = "default_channel: \"#ops-triage\"\nescalation_minutes: 15\n"
func main() {
cfg := flag.String("config", "/etc/oncall-router/oncall-router.yaml", "config file")
printDef := flag.Bool("print-default-config", false, "emit default YAML")
validate := flag.Bool("validate-config", false, "validate config without starting")
flag.Parse()
if *printDef { fmt.Print(defaultYAML); return }
raw, err := os.ReadFile(*cfg)
if err != nil || !strings.Contains(string(raw), "default_channel:") || strings.Contains(string(raw), "escalation_minutes: -") {
fmt.Fprintf(os.Stderr, "invalid config %s\n", *cfg); os.Exit(1)
}
if *validate { fmt.Println("config valid"); return }
fmt.Printf("loaded %d bytes from %s\n", len(raw), *cfg)
}
EOFconfig/oncall-router.yaml and create .confighub-bundle.yaml. Setting validate_cmd makes ConfigHub's PostToolUse hook automatically run --validate-config after every agent edit:
cd ~/oci-bundle-demo
go run ./main.go --print-default-config > config/oncall-router.yaml
cub bundle init \
--dir config \
--mount /etc/oncall-router \
--validate-cmd "go run ./main.go --validate-config --config config/oncall-router.yaml"
cat .confighub-bundle.yamlescalation_minutes: -5) fails before build, and restore valid defaults:
cd ~/oci-bundle-demo
cub bundle validate
printf 'default_channel: "#ops-triage"\nescalation_minutes: -5\n' > config/oncall-router.yaml
cub bundle validate || echo "caught invalid config before build"
go run ./main.go --print-default-config > config/oncall-router.yaml
cub bundle validatesha256: digest:
cd ~/oci-bundle-demo
cub bundle build --out dist/oncall-router-bundle.oci
cub bundle inspect dist/oncall-router-bundle.ocivolumes[].image PodSpec mounting the digest-pinned OCI bundle read-only at /etc/oncall-router:
cd ~/oci-bundle-demo
DIGEST=$(cub bundle inspect dist/oncall-router-bundle.oci --digest-only)
cub bundle podspec \
--app oncall-router \
--image ghcr.io/acme/oncall-router@sha256:example \
--ref "ghcr.io/acme/oncall-router-config@${DIGEST}" \
--mount /etc/oncall-router > k8s-podspec.yaml
cat k8s-podspec.yamlDelete ~/oci-bundle-demo. Nothing was pushed to a registry or applied to a cluster.
When packaging config into an immutable OCI bundle:
--config /etc/<app>/<app>.yaml, --print-default-config, and side-effect-free --validate-config.validate_cmd in .confighub-bundle.yaml so every config edit auto-validates.cub bundle validate before cub bundle build, never pack secrets into an OCI bundle, and pin volumes[].image.reference to @sha256:....runAsNonRoot: true, allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, capabilities.drop: [ALL], readOnly: true).Build a 20-line New 12-Factor Go service supporting --config, --print-default-config, and --validate-config, scaffold .confighub-bundle.yaml, catch a bad config with cub bundle validate, build a deterministic OCI Config Bundle, and emit a hardened Kubernetes 1.36+ volumes[].image PodSpec.
This proves: a New 12-Factor service wired with .confighub-bundle.yaml and cub bundle builds a deterministic OCI bundle and hardened Kubernetes 1.36+ volumes[].image PodSpec with zero in-place ConfigMap drift.