Skip to main content

Pod Structure

When you run hexr deploy, your agent becomes a Kubernetes Pod with exactly four containers plus an init container:

Init: install-hexr-sdk

Installs the Hexr SDK from private PyPI into a shared volume. Ensures the SDK version matches what was used during hexr build.

agent · :8080

Your Python code. Runs your @hexr_agent-decorated function. Listens on :8080 for inbound A2A bridge calls. Connects to SPIRE Workload API for SVID.

envoy-sidecar · :15001 / :15006

mTLS proxy. Terminates inbound TLS on :15006, initiates outbound mTLS on :15001. Loads X.509-SVIDs via SPIRE SDS. Routes /.well-known/* and /a2a traffic.

a2a-sidecar · :8090

Agent communication. JSON-RPC 2.0 dispatch (message/send, message/stream, tasks/get, tasks/cancel). Task state persisted in Valkey with SETNX idempotency.

pid-mapper · hostPID: true

Identity mapper. Reads /proc with host PID namespace access. Maps container PIDs to host PIDs. Writes enriched process context JSON for SPIRE workload attestation.

Container Details

1. Agent Container

Your Python code with the Hexr SDK. This is the only container you write code for.

2. Envoy Sidecar

Transparent mTLS proxy. Handles all network traffic in and out of the pod.
Envoy uses syscall.Exec PID inheritance — the envoy process “becomes” the proxy while maintaining the correct PID for SPIRE attestation. This is a novel technique described in the Hexr patent application.

3. A2A Sidecar

Implements the Agent-to-Agent protocol for inter-agent communication.

4. PID Mapper

Maps container PIDs to host PIDs for per-process SPIFFE identity.

Agent writes marker

When the agent process starts, the SDK writes a marker file to /tmp/hexr-context/:

PID Mapper translates

The PID Mapper reads /proc to map the container PID (42) to the host PID (83721). Writes the enriched JSON to /host-hexr-context/.

File Collector forwards

The File Collector DaemonSet reads from the hostPath volume and forwards the context to the Auto-Registrar via gRPC.

Auto-Registrar creates entry

The Auto-Registrar calls SPIRE Server’s CreateEntry API with per-process selectors (k8s:pod-uid, hexr:process-role).

SVID issued

The agent process fetches its X.509-SVID from the SPIRE Workload API, receiving a certificate with its per-process SPIFFE ID.

Shared Volumes

Three volumes connect the containers:

Init Container

Before the main containers start, an init container installs the Hexr SDK:
This ensures the SDK version matches what was used during hexr build, regardless of what’s baked into the agent image.

Network Flow

How a hexr_tool("aws_s3") call flows through the pod:

Agent calls hexr_tool('aws_s3')

SDK checks L1 in-memory cache, then L2 Valkey cache. Both miss.

Agent → Envoy (localhost)

Agent sends POST /exchange to the Envoy sidecar over localhost (plaintext, same pod).

Envoy → Credential Injector (mTLS)

Envoy initiates mutual TLS to the Credential Injector in hexr-system, attaching the agent’s X.509-SVID as the client certificate.

Credential Injector verifies + checks OPA

CI verifies the JWT-SVID via SPIRE Workload API, then queries OPA: “Can this SPIFFE ID access aws_s3?”

STS exchange

CI calls AssumeRoleWithWebIdentity on AWS STS, presenting the JWT-SVID as the web identity token. AWS trusts Hexr’s OIDC endpoint.

Credentials returned + cached

Temporary AWS credentials (15min TTL) flow back through Envoy to the agent. Stored in L1 + L2 cache. SDK creates an authenticated boto3 S3 client.
Subsequent calls hit the L1 in-memory cache (~0.001ms) or L2 Valkey cache (~1-3ms), avoiding the full exchange round-trip.