Kubernetes.LocalCluster reference
LocalCluster
Section titled “LocalCluster”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.
LocalCluster: Creating a Local Cluster
Section titled “LocalCluster: Creating a Local Cluster”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",});LocalCluster: Effect Programs
Section titled “LocalCluster: Effect Programs”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"), }; }),);LocalCluster: Kind Configuration
Section titled “LocalCluster: Kind Configuration”const cluster = yield* Kubernetes.LocalCluster("Cluster", { name: "alchemy", nodes: [ { role: "control-plane", extraPortMappings: [{ containerPort: 30080, hostPort: 8080 }], }, ],});LocalCluster: Registry Port
Section titled “LocalCluster: Registry Port”const blue = yield* Kubernetes.LocalCluster("Blue", { name: "blue" });const green = yield* Kubernetes.LocalCluster("Green", { name: "green", registryPort: 5002,});