Skip to content

Kubernetes

Host your Durable Objects on any Kubernetes cluster you can reach: EKS, GKE, kind on your machine, or your own. The control plane runs as a StatefulSet with a volume per engine, and each pool is a Deployment beside it.

src/cluster.ts
import * as RivetKubernetes from "@alchemy.run/rivet/Kubernetes";
import * as Layer from "effect/Layer";
export const Cluster = RivetKubernetes.StatefulSetControlPlane("Rivet", { cluster: Eks });
export const Default = RivetKubernetes.DeploymentPool("Default").pipe(Layer.provide(Cluster));

Install @alchemy.run/kubernetes. cluster takes a cluster resource or a kubeconfig. See Connecting to a cluster.

One engine keeps its data on its volume:

src/cluster.ts
export const Cluster = RivetKubernetes.StatefulSetControlPlane("Rivet", {
cluster: Eks,
diskSize: "20Gi",
});

More engines share object storage, so objectStorage is required:

src/cluster.ts
export const Cluster = RivetKubernetes.StatefulSetControlPlane("Rivet", {
cluster: Eks,
instances: 3,
objectStorage: { kind: "s3", bucket: "my-rivet-data", region: "us-west-2" },
});

kind: "gcs" uses a Cloud Storage bucket instead. The bucket must be reachable over HTTPS.

By default the control plane gets a LoadBalancer Service. On a cluster without load balancers, use a node port:

src/cluster.ts
export const Cluster = RivetKubernetes.StatefulSetControlPlane("Rivet", {
cluster: Kind,
expose: { type: "NodePort", nodePort: 30642, endpoint: "http://localhost:16450" },
});

Or use { type: "ClusterIP", endpoint } behind your own ingress.

src/cluster.ts
export const Default = RivetKubernetes.DeploymentPool("Default", { replicas: 3 }).pipe(
Layer.provide(Cluster),
);

The pool runs on the control plane’s cluster unless you pass cluster.

ServicesPool runs Rivet Services as a Deployment on the control plane’s cluster:

src/cluster.ts
export const Services = RivetKubernetes.ServicesPool("Services").pipe(Layer.provide(Cluster));

Every option, with its default, is in the reference: StatefulSetControlPlane, DeploymentPool and ServicesPool.