Skip to content

Kubernetes.LocalCluster reference

Source: src/Kubernetes/LocalCluster.ts

A Kubernetes cluster on your machine, for trying Alchemy’s Kubernetes resources and developing against them without a hosted cluster.

LocalCluster runs a kind cluster in Docker together with a local image registry wired into the cluster’s nodes, so workloads built from a main Effect program or a context Dockerfile work the same way they do on a hosted cluster with a registry. Pass the resource as the cluster of any Kubernetes.* resource.

Requires Docker and the kind CLI on the deploying machine (set KIND_BIN to use a specific binary). The cluster’s kubeconfig context, kind-<name>, works with kubectl.

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,
serviceType: "ClusterIP",
});
const cluster = yield* Kubernetes.LocalCluster("Cluster", {
name: "alchemy",
});
const hello = yield* Kubernetes.Job(
"Hello",
{ cluster, main: import.meta.url },
Effect.gen(function* () {
return {
run: Effect.log("hello from a Job"),
};
}),
);
const cluster = yield* Kubernetes.LocalCluster("Cluster", {
name: "alchemy",
nodes: [
{
role: "control-plane",
extraPortMappings: [{ containerPort: 30080, hostPort: 8080 }],
},
],
});
const blue = yield* Kubernetes.LocalCluster("Blue", { name: "blue" });
const green = yield* Kubernetes.LocalCluster("Green", {
name: "green",
registryPort: 5002,
});