← Back to Pull requests

vxpu/pki: mint CA and coordinator/agent SPIFFE certs from a Job #855

Closed
unknown closed this pull request without merging on Nov 24, 2026 02:59 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 23:26 UTC
Author

Implements the Kubernetes Job half of agent mutual TLS bootstrapping
(#662, #852): minting the certificate authority and workload SPIFFE
certificates without changing any existing network connections yet. The
local-directory command for single-machine use without a cluster is split
out to a follow-up pull request to keep this change focused and small.

Approach:

  • Add vxpu/pkg/pki using only the Go standard library (crypto/ecdsa

  • P-256, crypto/x509) and k8s.io/client-go with no new dependencies.
  • Mint a self-signed CA (vxpu-ca, 1-year default TTL, path length 0)

  • and leaf certificates (30-day default TTL) carrying a single SPIFFE URI
    SAN and no DNS or IP SANs so SPIRE or another issuer can replace this
    Job later:
    - coordinator: spiffe://<trust-domain>/ns/<ns>/sa/vxpu-router with
    ClientAuth EKU (vxpu-coordinator-tls),
    - pod agents: spiffe://<trust-domain>/ns/<ns>/sa/vxpu-agent with
    ServerAuth EKU (vxpu-agent-tls).
  • Store vxpu-ca (ca.crt, ca.key) in a dedicated vxpu-pki

  • namespace so the router cannot mount it onto pods in the workload
    namespace, and refuse configurations where the CA and workload
    namespaces match or where an existing vxpu-ca is malformed or expired.
  • Keep re-runs idempotent and consistent: verify every existing leaf

  • against the current CA, matching private key, expected SPIFFE ID and
    EKU, and expiry. Valid leaves stay unchanged (status="kept"); stale
    vxpu-ca-bundle ConfigMaps are updated to the current CA
    (status="updated"), and missing, expired, mismatched, or wrong-CA
    leaves are minted from vxpu-ca (status="created" or
    status="re-minted" with the reason). Log identities, expiries,
    status, and reason via klog, never key material.
  • Add vxpu/images/pki-init/Dockerfile (golang:1.27.4 builder,

  • distroless nonroot UID 65532), vxpu/k8s/pki-init.yaml
    (least-privilege namespaced RBAC with scoped update on the workload
    ConfigMap and leaf Secrets only, zero-RBAC vxpu-agent ServiceAccount,
    hardened Job), unit tests in vxpu/pkg/pki/pki_test.go, kind e2e
    coverage in vxpu/tests/e2e/pki_test.go, and a trust-model section in
    vxpu/docs/design.md.

    Verification:

  • ap generate --verify //..., ap lint vxpu, and ap test vxpu pass.

  • Built vxpu-pki-init:e2e and verified three Job runs in kind

  • (kindest/node:v1.37.0) with vxpu/k8s/pki-init.yaml and the router
    RBAC from vxpu/cmd/vxpu/router.yaml:
    1. Initial mint created vxpu-ca, vxpu-ca-bundle (no private key),
    vxpu-coordinator-tls, and vxpu-agent-tls; kubectl auth can-i
    get secret/vxpu-ca -n vxpu-pki
    returned no for vxpu-router,
    vxpu-agent, and default, and yes for vxpu-pki-init.
    2. Deleting vxpu-agent-tls and re-running kept vxpu-ca,
    vxpu-ca-bundle, and vxpu-coordinator-tls unchanged and recreated
    vxpu-agent-tls.
    3. Deleting vxpu-ca while leaving the old bundle and leaves in place
    and re-running minted a new CA, updated vxpu-ca-bundle, and
    re-minted both leaves with status="re-minted" and the verification
    failure reason in the Job logs (zero key material logged).
  • go test -c ./tests/e2e compiles cleanly; the full ap-e2e-vxpu

  • presubmit runs testPKIInit inside TestE2E.

    Fixes #852

    Diff: 413 lines (+309 / -104) across 5 files Reviewer: codebot-robot Review duration: 213m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 413 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.361
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #855"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%