Skip to content

Kubernetes

Kubernetes is the open-source standard for running containers across a cluster of machines, and every major cloud offers it as a managed service.

You describe what should exist, three copies of this server, a job every night, an address in front of them, and the cluster works continuously to make it so, restarting what crashes and moving what was on a machine that died. It runs anywhere, from your laptop to your own servers to EKS, GKE or AKS.

New to Kubernetes? Start with What is Kubernetes?.

A cluster to deploy to. LocalCluster starts one on your machine, so you can try everything without a hosted cluster:

alchemy.run.ts
const cluster = yield* Kubernetes.LocalCluster("Cluster", { name: "alchemy" });

A replicated server from a public image, with a Service in front of it:

alchemy.run.ts
const web = yield* Kubernetes.Deployment("Web", {
cluster,
image: "ghcr.io/stefanprodan/podinfo:6.15.0",
port: 9898,
replicas: 2,
});

And the Stack that holds them:

alchemy.run.ts
import * as Alchemy from "alchemy";
import * as Kubernetes from "@alchemy.run/kubernetes";
import * as Effect from "effect/Effect";
export default Alchemy.Stack(
"MyApp",
{ providers: Kubernetes.providers(), state: Alchemy.localState() },
Effect.gen(function* () {
const cluster = yield* Kubernetes.LocalCluster("Cluster", { name: "alchemy" });
const web = yield* Kubernetes.Deployment("Web", {
cluster,
image: "ghcr.io/stefanprodan/podinfo:6.15.0",
port: 9898,
replicas: 2,
});
return { service: web.serviceName };
}),
);

When you’re ready, point the same resources at a real cluster.

Want to build? The tutorial goes from an empty directory to a local cluster running a service, Effect Jobs, a CronJob and a Helm chart, and ends on a cluster of your own. Start with Setup.

Looking for something specific? Every section of these docs is listed below, and every resource is in the generated API reference.