Skip to content

Cluster.Kubernetes reference

Source: packages/effect-cluster/src/Kubernetes/Database.ts

The database an Effect Cluster coordinates through, on Kubernetes, as a Cluster.Database Layer: Postgres as a Deployment behind a ClusterIP Service, on the cluster the runners run on. Nothing outside the cluster reaches it.

Its data lives in the pod, so it is meant for development and tests; for a managed Postgres (RDS, Cloud SQL, Neon), pass its URL to Cluster.Database.fromUrl and give the pool its cluster.

Database: Running the database on Kubernetes

Section titled “Database: Running the database on Kubernetes”
export const Kind = Kubernetes.LocalCluster("Kind", { name: "cluster" });
export const Database = ClusterKubernetes.Database("Cluster", { cluster: Kind });

Source: packages/effect-cluster/src/Kubernetes/DeploymentPool.ts

Run a pool of Effect Cluster runners on Kubernetes: a Deployment whose pods host every class given this pool, in the database’s cluster and namespace. Pods reach each other at their own addresses; the gateway is a Service of the Deployment, at http://{name}.{namespace}.svc.cluster.local:34500 for callers in the cluster. Requires a database on a Kubernetes cluster — ClusterKubernetes.Database.

export const Database = ClusterKubernetes.Database("Cluster", { cluster: Kind });
export const Default = ClusterKubernetes.DeploymentPool("Default", { replicas: 2 }).pipe(
Layer.provide(Database),
);