Skip to content

Kubernetes & OpenShift

For production workloads, Alquimia Platform runs as a Kubernetes workload with separate master and worker deployments. This separates request intake from execution, lets you scale each role independently, and supports Vault-backed dynamic credentials and SPIFFE workload identity.

The runtime does not provision its own backing services. The manifests in alquimia-runtime/k8s deploy the master, workers, services, and network policies into the alquimia-runtime namespace. Everything else must already exist, and backing services are expected in namespaces labelled alquimia.ai/namespace-role: backend.

flowchart TB
  clients["Client apps · browsers · channels"]
  llm["LLM, MCP and A2A endpoints<br/>HTTPS 443"]

  subgraph cluster["Kubernetes / OpenShift cluster"]
    router["Ingress controller / OpenShift Router<br/>TLS termination"]

    subgraph ns_studio["ns: alquimia-studio"]
      studio["Studio :3000"]
    end

    subgraph ns_rt["ns: alquimia-runtime"]
      master["master ×1<br/>HTTP API :8080 · registry writer"]
      workers["workers ×N<br/>alquimia-core execution"]
    end

    kafka[("Kafka<br/>alquimia.events · .dlq")]

    subgraph ns_backend["backend namespaces · alquimia.ai/namespace-role=backend"]
      pg[("PostgreSQL")]
      redis[("Redis")]
      qdrant[("Qdrant<br/>master only")]
      s3[("S3 object store")]
      vault["Vault"]
      oci["OCI registry"]
    end

    subgraph ns_platform["platform services"]
      kc["Keycloak"]
      spire["SPIRE"]
      otel["OTel Collector"]
    end
  end

  clients --> router
  router --> studio
  router --> master
  studio --> master
  master -->|"signed CloudEvents"| kafka
  kafka -->|"consumer group"| workers
  master --> ns_backend
  workers --> ns_backend
  workers -->|"egress 443"| llm
  ns_platform -.->|"OIDC · SVIDs · OTLP"| ns_rt

Solid arrows are request and data paths. The dotted arrow covers identity and telemetry: Keycloak token validation, SPIFFE SVIDs over the CSI socket, and OTLP on 4317/4318. Qdrant is reached only by the master; the worker network policy does not grant Qdrant egress.

RoleResponsibilityScaling driver
MasterAccepts HTTP requests, manages registry, publishes eventsFixed at exactly 1 replica (Recreate strategy)
WorkerConsumes events and executes agentsInference throughput, up to the alquimia.events partition count (6)

Workers are stateless. You can add replicas to increase throughput without changing the master deployment, up to the number of partitions on alquimia.events; extra workers stay idle.

The master is the single writer of the TinyDB registry (protected by a Redis Redlock). Run exactly one master replica with the Recreate deployment strategy; do not scale or autoscale it. The Recreate strategy is required both for RWO PVC attachments and because two master pods would race as dual registry writers.

The registry lives on the master and is mirrored to object storage so workers can read it. Every pod uses rclone init containers and sidecars for this:

flowchart LR
  subgraph master_pod["master pod"]
    m_init["init: create-bucket<br/>init: fetch-registry<br/>rclone copy --ignore-existing"]
    m_rt["alquimia-runtime<br/>registry R/W"]
    m_sync["sidecar: s3-sync<br/>rclone sync local → S3"]
  end
  s3[("S3 bucket<br/>registry/ prefix")]
  subgraph worker_pod["worker pod ×N"]
    w_init["init: fetch-registry<br/>rclone sync S3 → local"]
    w_sync["sidecar: s3-sync<br/>rclone sync S3 → local"]
    w_rt["alquimia-runtime<br/>registry read-only"]
  end
  s3 --> m_init --> m_rt
  m_rt --> m_sync --> s3
  s3 --> w_init --> w_rt
  s3 --> w_sync --> w_rt

Both master and worker pods run an init container that pulls the published registry from S3 before the runtime starts. The init container exits with the rclone return code, so Kubernetes restarts the pod when S3 is unavailable, except for exit code 3 (no registry published yet), which is treated as a successful empty start. The sidecars resync every SYNC_INTERVAL seconds (default 30), so registry changes reach workers with that delay.

The runtime repository provides overlays for different environments:

OverlayUse
kubernetesVanilla Kubernetes without admission policies.
productionVanilla Kubernetes with Kyverno admission policies in Enforce mode (image signature verification and pod security).
openshiftOpenShift / ROSA; relies on OpenShift Security Context Constraints (SCCs) instead of Kyverno. Master registry on a PVC.
spire-openshiftDeploys the SPIRE manifests (k8s/spire) with the agent patches OpenShift needs; used for SPIFFE workload identity, separately from the runtime overlay.

Two further kustomizations are applied separately: k8s/kafka-config (Strimzi KafkaTopic and KafkaUser resources, applied into the Kafka cluster’s namespace) and k8s/autoscaling (a KEDA ScaledObject, shipped paused).

Always deploy through the openshift overlay on OpenShift, never k8s/base directly. Review these points before the first apply:

  • SCC. The overlay removes the fixed runAsUser/runAsGroup/fsGroup: 1000 values from the base so the restricted-v2 SCC can inject a UID from the namespace range. Check which SCC each pod was admitted under with oc get pod <pod> -o jsonpath='{.metadata.annotations.openshift\.io/scc}'. Runtime pods should not need anyuid or privileged.
  • Registry PVC. The master’s registry is mounted from a PVC called alquimia-registry-s3, which the overlay does not create. Create an RWO claim before applying.
  • Image tag. The overlay pins docker.io/alquimiaai/runtime to a specific tag in kustomization.yaml. Set it to the release you are deploying, preferably by digest, and mirror the image into your internal registry.
  • Sidecar images. The rclone init containers and sidecars reference docker.io/rclone/rclone:latest. In production, mirror this image and pin it by digest so it passes registry allow-lists and stays reproducible.
  • Cluster-specific patches. Several overlay patches encode one reference environment: the Kubernetes API egress rule (ROSA hosted control plane IPs), a Postgres colocated in the runtime namespace with label app: postgresql, and Redis pods labelled app: redis-stack-server. Adapt them to your cluster’s labels and addresses, or remove them.
  • Routes. OpenShift exposes the master through a Route rather than an Ingress. Use edge or re-encrypt TLS termination: oc create route edge alquimia-runtime --service=alquimia-runtime --hostname=api.alquimia.<your-domain>.
  • SPIRE. The SPIRE agent and SPIFFE CSI driver need the privileged SCC (host PID, host network, and hostPath). The spire-openshift overlay grants it only to those two service accounts and labels the CSIDriver so restricted-v2 workloads can mount it.
  • Use projected service-account tokens (audience vault) and the Kubernetes Vault auth method for runtime services. Set both VAULT_K8S_ROLE (runtime) and VAULT_AUTH_ROLE (alquimia-core secret resolver); the manifests do not use a static VAULT_TOKEN.
  • Bind Vault roles to one Kubernetes ServiceAccount each. Master and worker use separate ServiceAccounts, and the worker’s ServiceAccount has automountServiceAccountToken: false so worker pods cannot mount the Kubernetes API token by default.
  • Use SPIFFE/SPIRE and the JWT Vault auth method for per-agentspace agent identities. On OpenShift, SPIRE ClusterStaticEntry RBAC and the admission policy that protects it live in the spire-openshift overlay.
  • Enable image signature verification in production overlays. Agentspace and Boltzmann brain pulls also require a cosign key (ALQUIMIA_OCI_COSIGN_PUBKEY) because ALQUIMIA_OCI_SIGNATURE_POLICY defaults to required.
  • Store sensitive values in Vault, not in ConfigMaps or environment variables.
  • Every container runs with a read-only root filesystem, all capabilities dropped, and the RuntimeDefault seccomp profile. Writable paths are limited to /tmp, /var/lib/alquimia/registry, and /var/lib/alquimia/cache.
  • Pin all sidecar and utility images by digest in production overlays, including rclone, SPIRE, the SPIFFE CSI driver, and busybox.
  • Restrict worker egress with NetworkPolicy and, where possible, an egress proxy or firewall so workers can reach only approved LLM, MCP, identity, and backend destinations.

The base manifests ship a default-deny policy for the alquimia-runtime namespace plus explicit allow rules:

PolicyAllows
default-deny-allNothing: denies all ingress and egress for every pod in the namespace.
allow-dnsDNS to kube-dns and the OpenShift DNS daemonset.
allow-runtime-health-probesKubelet probes on TCP 8080.
allow-master-ingressTCP 8080 to the master from the router (network.openshift.io/policy-group: ingress) and from the alquimia-studio namespace.
allow-master-to-backendsMaster egress to PostgreSQL, Redis, Qdrant, Alarik, Vault, Kafka, and the OCI registry in backend namespaces.
allow-worker-to-backendsThe same for workers, without Qdrant.
allow-worker-llm-mcp-egressWorker egress to any address on TCP 443, for LLM and MCP endpoints.
allow-otelOTLP egress on 4317/4318 to pods labelled opentelemetry-collector or otel-collector.

Backend rules match on both a namespace label and a pod label. For example, the blob-store rule allows TCP 8080 to pods labelled app.kubernetes.io/name: alarik in namespaces labelled alquimia.ai/namespace-role: backend. The reference stack uses Alarik on that port. If your blob store runs elsewhere, label its namespace or add an equivalent rule:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-runtime-to-objectstore
namespace: alquimia-runtime
spec:
podSelector:
matchExpressions:
- key: role
operator: In
values: [master, worker]
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
alquimia.ai/namespace-role: backend
podSelector:
matchLabels:
app.kubernetes.io/name: alarik
ports:
- protocol: TCP
port: 8080

Runtime pods are selected by the role label (master or worker) and app: alquimia-runtime.

  1. Provision a PostgreSQL database, Redis cache, Qdrant vector store, Kafka cluster, and object store. Size PostgreSQL max_connections for the runtime’s per-process pools (see Runtime configuration).
  2. Label backend namespaces alquimia.ai/namespace-role=backend and check that backend pods carry the app.kubernetes.io/name labels the network policies expect.
  3. Apply k8s/kafka-config to create the alquimia.events (6 partitions) and alquimia.events.dlq topics and the master and worker KafkaUser ACLs, then confirm the topic reports 6 partitions.
  4. Set up Vault with the Kubernetes auth method. Bind separate Vault roles to the alquimia-runtime-master and alquimia-runtime-worker ServiceAccounts, configure policies and secrets, and set automountServiceAccountToken: false on the worker ServiceAccount.
  5. Generate the KAFKA_SIGNING_KEY and ENCRYPTION_KEY, and the cosign key pair used to sign agentspaces and Boltzmann brains.
  6. Optionally deploy SPIRE (spire-openshift overlay on OpenShift) and Keycloak.
  7. Create the namespace, image pull secret, and, on OpenShift, the alquimia-registry-s3 PVC.
  8. Configure an Ingress or Route for the master API, and point OTLP endpoints at your collector.