Files
archie/docs/enterprise/deployment-architecture.md
T

8.6 KiB

Enterprise Deployment Architecture

Archie runs as a single static binary (cmd/archie) backed by PostgreSQL. Regulated deployments isolate each stage, separate DDL from DML credentials, split external webhook ingress from internal operator access, and enforce strict pod or container boundaries.

Multi-Stage Isolation Zones

Deploy Archie into three independent stages: dev, staging, and prod. Each stage runs its own Archie instance and shares no runtime state with any other stage.

Resource dev staging prod
Kubernetes namespace or host archie-dev archie-staging archie-prod
PostgreSQL database Isolated dev instance Isolated staging instance Managed HA PostgreSQL (sslmode=verify-full)
age sealing key Stage-local age_identity Stage-local age_identity Stage-local age_identity with offline age_backup_recipients
OIDC client Non-prod IdP client Staging IdP client Production IdP confidential client
Earned autonomy Local to dev Local to staging Built independently in prod
Helm overlay values-dev.yaml values-staging.yaml values-prod.yaml

Earned autonomy in staging never promotes to prod. Promote declarative configuration (workflows, Cedar policies, judgement rules, and action-type metadata) with archie bundle. Keep credentials, OIDC bindings, target hosts, and autonomy counters local to each stage.

Pin container images by immutable SHA-256 digest (image.digest in Helm) and verify cosign signatures before deploying to staging and prod. Set [catalogue] disable_auto_update = true and mirror signed extension catalogues internally in air-gapped stages.

Stage Promotion Models

Choose one of two promotion workflows depending on your delivery pipeline:

  1. Push CI/CD (GitHub Actions, GitLab CI, or Jenkins):
    • On pull requests, run archie bundle validate offline to check workflow YAML, Cedar policy syntax, judgement rules, and stage Bindings without database access.
    • Export the tested bundle from staging and record its canonical SHA-256 digest (Bundle.Digest()).
    • After manual change approval, the prod pipeline runs archie bundle apply --expect-digest <sha256> over HTTPS using ARCHIE_URL and ARCHIE_TOKEN_FILE. The CI runner never touches PostgreSQL directly.
  2. Pull GitOps (Argo CD or Flux):
    • Store the stage Helm values (values-staging.yaml, values-prod.yaml), bundle.yaml, and stage-local bindings.yaml in Git.
    • Enable bundleSync.enabled: true in deployments/helm/archie to run templates/job-bundle-sync.yaml as an Argo CD PostSync or Helm post-install,post-upgrade Job.
    • The Job mounts the bundle ConfigMap, uses only the runtime archie_app database secret (ARCHIE_DATABASE_URL_FILE), and applies unchanged bundles idempotently with optional expectDigest verification.

Split Ingress and Network Boundaries

Separate external webhook delivery from operator and administrator access using two ingress resources (deployments/helm/archie/templates/ingress.yaml):

  1. Perimeter webhook ingress (ingress.perimeter): Expose only webhook intake paths (/hooks/ for cmd/archie intake and /webhooks/ where routed by a reverse proxy). Terminate TLS at the edge and apply rate limits. The events module verifies each payload's HMAC signature before parsing JSON (modules/events/verify.go).
  2. Internal operator ingress (ingress.internal): Serve the Dashboard, /api/, and OIDC routes behind a corporate VPN or internal load balancer. Never expose /api/ or the setup surface on the perimeter ingress.

Enforce default-deny NetworkPolicy rules (deployments/helm/archie/templates/networkpolicy.yaml) in staging and prod. Permit ingress only from the perimeter ingress controller (port 8080), internal ingress controller (port 8080), and Prometheus scraper (port 9090 on /metrics). Permit egress only to DNS (53), PostgreSQL or PgBouncer (5432), the OIDC issuer (443), configured remote extension endpoints, the corporate proxy (HTTPS_PROXY), and the OpenTelemetry collector (4317).

Database Role Split and PgBouncer Session Pooling

Archie separates schema ownership from runtime operations across two PostgreSQL roles:

  • archie_owner (ARCHIE_DATABASE_OWNER_URL_FILE): Holds DDL rights. Used only by archie migrate inside the Helm pre-install/pre-upgrade Job (job-migrate.yaml) or the Compose archie-migrate init service (deployments/archie/compose.enterprise.yml).
  • archie_app (ARCHIE_DATABASE_URL_FILE): Holds only USAGE and DML privileges (SELECT, INSERT, UPDATE, DELETE, and SELECT on public.goose_db_version). The runtime StatefulSet and Compose archie service mount only this credential. At startup, pg.VerifySchema (internal/platform/pg/pg.go) checks that every embedded migration is applied and fails closed if the schema lags behind.

PgBouncer Session-Pooling Requirement for ClaimServe

At boot, cmd/archie calls pg.ClaimServe (internal/platform/pg/pg.go). ClaimServe opens a dedicated connection via db.Conn(ctx) and acquires a shared PostgreSQL session advisory lock (pg_try_advisory_lock_shared(hashtextextended('archie.serve.owner', 0))). It holds that lock for the entire lifetime of the serving process. A database restore takes the same key exclusively so no serving pod can start or run during a restore window.

If you deploy PgBouncer in front of PostgreSQL, configure pool_mode = session for Archie's runtime pool. PgBouncer transaction and statement pooling modes share server backends across clients and release or drop session advisory locks between transactions. Direct connections to the HA PostgreSQL primary also satisfy this requirement.

Pod Security and Extension Confinement

Extension execution differs between Kubernetes and Docker Compose because Kubernetes restricted Pod Security Standards forbid user namespaces.

Control Kubernetes (deployments/helm/archie) Hardened Compose (deployments/archie/compose.enterprise.yml)
User and root filesystem runAsNonRoot: true, UID/GID 65532, read-only root filesystem, allowPrivilegeEscalation: false, capabilities.drop: [ALL] user: "65532:65532", read_only: true, tmpfs: /tmp, cap_drop: [ALL], no-new-privileges:true
Seccomp profile seccompProfile.type: RuntimeDefault deployments/archie/seccomp.json (Docker default plus clone for namespaces)
Extension runtime RemoteGRPCRuntime over mTLS or Unix socket (require_remote = true) LocalNamespaceRuntime (CLONE_NEWUSER and CLONE_NEWNET)
Egress proxy and PKI HTTPS_PROXY, NO_PROXY, and SSL_CERT_FILE propagated to runtime and NetworkPolicy HTTPS_PROXY, NO_PROXY, and SSL_CERT_FILE propagated into confined namespaces

In Kubernetes, run extensions as separate Pods or sidecars under restricted Pod Security Standards and isolate them with NetworkPolicy. Configure [extensions] in config.toml (templates/configmap.yaml) with require_remote = true, TLS 1.3 mTLS certificates (ca_file, cert_file, key_file), and explicit [extensions.remote.<name>] targets. If neither RemoteGRPCRuntime nor LocalNamespaceRuntime is available, modules/connectors/internal/host/remote.go fails closed.

In Docker Compose and VM hosts, LocalNamespaceRuntime confines each extension binary in its own user and network namespace behind an allow-list forward proxy (modules/connectors/internal/egress/tunnel.go). The tunnel enforces Archie's host allow-list and loopback checks before chaining allowed traffic through HTTPS_PROXY.

Probes, Graceful Drain, and High Availability

cmd/archie exposes three health endpoints (internal/platform/health/health.go):

  • /healthz: Liveness probe. Returns 200 while the HTTP server process is alive.
  • /startupz: Startup probe. Verifies database connectivity and confirms the deletion ledger is consistent before Kubernetes routes traffic or triggers liveness checks.
  • /readyz: Readiness probe. Requires /startupz checks plus completion of owner setup (gate.go), and returns 503 as soon as SIGTERM begins draining.

Set terminationGracePeriodSeconds (45 seconds in values-prod.yaml) higher than shutdown_grace (30s) so in-flight HTTP requests and run checkpoints finish before SIGKILL.

Enterprise v1 runs Active-Passive HA with replicaCount: 1 on a StatefulSet backed by a ReadWriteOnce PVC for state_dir. Never scale replicaCount above 1 in v1 without shared state_dir storage and v2 Active-Active coordination (LISTEN/NOTIFY hub, lease election, and object-lock deletion ledger).