vxpu/pki: write CA and SPIFFE certificates to a local directory #872
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 355 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #872"
general
weight: 0.35
codebot-robot
Implement the single-machine half of the first mTLS move (#662, #855)
so a laptop or single VM with no Kubernetes cluster can generate the
same CA and SPIFFE leaf certificates as files with one command.
Approach:
minting and verification code as EnsureK8s. It writes ca.crt and
ca.key under <dir>/ca, and writes ca.crt, tls.crt, and tls.key under
<dir>/coordinator and <dir>/agent without placing ca.key in either
workload directory.
private keys with mode 0600 (from os.CreateTemp through rename) and
certificates with mode 0644. Stage a newly minted CA pair inside a
temporary directory (<dir>/.ca.tmp-) and rename it to <dir>/ca so
ca.crt and ca.key appear together or not at all; remove stale
.ca.tmp- staging directories on subsequent runs so a killed process
never leaves an orphaned CA private key behind.
update stale workload ca.crt bundles, re-mint missing, expired,
mismatched, or wrong-CA leaves from the CA in <dir>/ca, and refuse a
malformed, expired, non-CA, or incomplete CA without overwriting any
existing file. Log identities, expiries, status, and reason via klog
with no private key material.
cmd/vxpu. vxpu-pki-init already owns the PKI flags (--trust-domain,
--workload-namespace, --ca-ttl, --leaf-ttl) and parallels the other
standalone binaries (vxpu-agent, vxpu-router) run on a single host.
Putting --out-dir on vxpu-pki-init avoids duplicating the PKI flag
surface onto cmd/vxpu and keeps cluster and single-machine runs
identical in flags and log output. Check whether --out-dir was passed
via FlagSet.Visit so an explicit --out-dir "" fails with an empty
directory error rather than falling through to Kubernetes mode. When
--out-dir is set, run ignores KUBECONFIG from the environment,
rejects --kubeconfig passed explicitly alongside --out-dir, checks
errors early, and exits from main in one place.
one-machine runs intentionally keep the cluster service-account SPIFFE
identities and what --workload-namespace means without a cluster. Add
unit tests in vxpu/pkg/pki/pki_test.go and
vxpu/cmd/vxpu-pki-init/main_test.go.
Verification:
go test -race ./pkg/fileutil/... ./pkg/pki/... ./cmd/vxpu-pki-init/... ./pkg/agent/...
pass.
temp directory and verified 0600 key permissions, 0644 cert
permissions, and status="created" followed by status="kept" logs.
Fixes #870