Commit 3fbac5e
feat(deploy): AKS read-only deploy hardening (sub-project 2)
Enables `codeiq serve` inside an AKS pod with
`securityContext.readOnlyRootFilesystem=true` and a writable `/tmp`,
without source-code changes to the serve profile or Neo4j wiring. The
deploy contract is solved at the deployment layer plus a JVM-flag-preset
launch wrapper.
Deploy shape:
Build CI: index → enrich → bundle → upload to Nexus
AKS pod:
init-container: pull bundle.zip from Nexus → unzip into /tmp/codeiq-data
main container: scripts/aks-launch.sh /tmp/codeiq-data
→ java [JVM flag preset] -jar code-iq.jar serve /tmp/codeiq-data
Why init-container copy + flag preset over alternatives:
- vs. Neo4j read-only mode + tmp redirects: embedded Neo4j 2026.04.0
still acquires a `store_lock` file at open; per-version fragility
isn't worth fighting when /tmp is writable.
- vs. baking the bundle into the container image: container's writable
upper layer is also read-only when mounted --read-only, so Neo4j
still fails. Plus large image, cadence coupling.
- vs. swapping Neo4j for a static snapshot at serve time: throws away
the entire read API surface (Cypher, indexes, full-text search).
Reserved as the fallback if init-container copy proves operationally
insufficient — out of scope here.
JVM flag preset (encoded in scripts/aks-launch.sh):
-Dorg.springframework.boot.loader.tmpDir=/tmp/spring-boot-loader
Spring Boot fat JAR extracts nested JARs to ~/.m2/spring-boot-loader-tmp
by default — outside /tmp, fails under read-only HOME.
-Djava.io.tmpdir=/tmp
Explicit even though /tmp is the Linux default — multipart upload
temps, JNA / Netty native lib extraction all use this; making it
explicit means base-image-default drift can't break us.
-XX:ErrorFile=/tmp/hs_err_pid%p.log
-XX:HeapDumpPath=/tmp
-XX:+HeapDumpOnOutOfMemoryError
JVM crash + heap-dump default is cwd. cwd under read-only root =
unwritable. These redirect to /tmp so dumps survive for kubectl cp.
Files in this commit:
- docs/specs/2026-04-28-aks-read-only-deploy-design.md — architecture
spec: problem, approach, audit table (Neo4j store_lock,
spring-boot-loader, JVM crash files, logback, H2 cache, SPA static),
test approach (sentinel + docker smoke), risks, acceptance criteria.
Logback was verified console-only via src/main/resources/logback-
spring.xml — no file appender redirect needed.
- docs/plans/2026-04-28-sub-project-2-aks-read-only-deploy.md — task
list (5 tasks, single PR), file map, acceptance gates, deliberate
out-of-scope items.
- shared/runbooks/aks-read-only-deploy.md — canonical operational
runbook: deploy shape, full Kubernetes Pod manifest snippet (init
container + main container with SecurityContext, volume mounts,
probes, resource limits), reference Dockerfile, JVM flag preset
table, three verification gates (local docker smoke, sentinel test,
in-cluster smoke), rollback, troubleshooting matrix.
- scripts/aks-launch.sh — the launch wrapper. set -euo pipefail, arg
validation, JAR location resolution (/app/code-iq.jar default,
$CODEIQ_JAR override), 1 GB /tmp pre-flight, mkdir
/tmp/spring-boot-loader, exec java to PID 1.
- src/test/java/.../deploy/AksLaunchScriptSentinelTest.java — 11
sentinel tests asserting every required flag, the strict-bash mode,
arg-count validation, exec-to-pid-1 contract, and the /tmp pre-flight
floor are present in scripts/aks-launch.sh. Catches drift on refactor.
- CHANGELOG.md — [Unreleased] / Added entry.
- shared/runbooks/engineering-standards.md §7.1.1 — new subsection
cross-linking the runbook + script for downstream consumers running
on hardened container runtimes.
Tests: mvn test → 3427 / 0 failures / 31 skipped (full suite). The
delta from a sub-project-1 branch run (3618) is the ~190 sub-project-1
tests that haven't merged yet — independent and expected.
Out of scope for this PR (deliberate, listed in spec §3 + plan):
- Heavyweight JVM-level filesystem-write detector (Java has no clean
chroot/unshare API; environment-fragile in CI). The runbook docker
smoke is the SSoT for "did this actually work in a RO root."
- /api/diagnostics endpoint surfacing JVM flag preset values.
- Static-snapshot storage layer rewrite (Approach D in the spec).
- Helm / OCI artifact packaging — runbook ships vanilla Kubernetes
manifest; productionizing into Helm is the deployer's call.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5a46598 commit 3fbac5e
7 files changed
Lines changed: 767 additions & 0 deletions
File tree
- docs
- plans
- specs
- scripts
- src/test/java/io/github/randomcodespace/iq/deploy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
| |||
Lines changed: 156 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
0 commit comments