Skip to content

Rivet.Hetzner reference

Source: packages/rivet/src/Hetzner/ServerControlPlane.ts

A Rivet control plane on Hetzner Cloud, as a Rivet.Cluster Layer: Servers running the engine container, each with a Volume of its own, on a private Network they talk to each other over, behind a private Load Balancer. An edge Server runs Caddy in front of it and serves the engines over HTTPS at its own address under sslip.io (https://203-0-113-7.sslip.io), with a certificate from Let’s Encrypt, so it needs no domain of your own. A firewall drops every other inbound connection to the engines. A namespace is created for the stage.

One engine keeps actor data on its Volume. Several share it through objectStorage — Hetzner Object Storage, or any S3-compatible bucket.

Pools of nodes anywhere reach it at its public address — RivetHetzner.ServerPool on Hetzner, or a pool on any other cloud.

ServerControlPlane: Running a control plane on Hetzner

Section titled “ServerControlPlane: Running a control plane on Hetzner”

One engine

export const Cluster = RivetHetzner.ServerControlPlane("Rivet");

Three engines sharing Hetzner Object Storage

export const Cluster = RivetHetzner.ServerControlPlane("Rivet", {
instances: 3,
objectStorage: {
kind: "s3",
bucket: "my-rivet-data",
endpoint: "https://nbg1.your-objectstorage.com",
region: "nbg1",
accessKeyId: Config.String("HETZNER_S3_ACCESS_KEY_ID"),
secretAccessKey: Config.Redacted("HETZNER_S3_SECRET_ACCESS_KEY"),
},
});

Source: packages/rivet/src/Hetzner/ServerPool.ts

Run a pool’s nodes on Hetzner Cloud: a pool on the control plane, and Servers that each run every Rivet.DurableObject given this pool as a Hetzner.Service. Nodes only connect out to the control plane, so a firewall drops every inbound connection except SSH, which deploys them; the pool works with any control plane it can reach — RivetHetzner.ServerControlPlane, RivetCloud.ControlPlane, or one on another cloud.

Every Durable Object given the same pool shares its nodes: declare the pool once and provide it to each class.

Hetzner Cloud has no secret store and no instance identity a node could read one with, so the control plane’s token, and every secret a class reads as config, are copied over SSH into an env file on each Server that only root can read. They never go into the Server’s user data, which any process on it can read from the metadata service. Root on the Server can still read them.

ServerPool: Running Durable Objects on Hetzner

Section titled “ServerPool: Running Durable Objects on Hetzner”
export const Cluster = RivetHetzner.ServerControlPlane("Rivet");
export const Default = RivetHetzner.ServerPool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Source: packages/rivet/src/Hetzner/ServicesPool.ts

Run Rivet Services on Hetzner Cloud: the services pool on the control plane, and Servers running Rivet’s prebuilt Services node on Docker, which hosts Durable Streams and agentOS. A firewall drops every inbound connection except SSH, which deploys the nodes: callers reach every stream through the control plane’s gateway, with its token. Works with any control plane it can reach.

Hetzner Cloud has no secret store and no instance identity a node could read one with, so the control plane’s token is copied over SSH into an env file on each Server that only root can read. It never goes into the Server’s user data, which any process on it can read from the metadata service. Root on the Server can still read it.

ServicesPool: Running Rivet Services on Hetzner

Section titled “ServicesPool: Running Rivet Services on Hetzner”
export const Cluster = RivetHetzner.ServerControlPlane("Rivet");
export const Services = RivetHetzner.ServicesPool("Services").pipe(Layer.provide(Cluster));