Skip to content

Kubernetes.Workloads reference

Source: src/Kubernetes/Deployment.ts

A replicated Kubernetes server on any cluster — the Kubernetes analog of AWS.ECS.Service.

Deployment provisions a Kubernetes Deployment + Service (+ ServiceAccount) via server-side apply, plus — through the target cluster’s platform adapter — workload identity and a container image from exactly one of three sources flat on props: main (bundle an inline Effect program), context (build your own Dockerfile), or image (a pre-built registry reference). On AWS.EKS.Cluster targets it accepts the same { env, policyStatements } host binding contract as AWS.Lambda.Function and AWS.ECS.Task: every AWS Binding.Service (S3, DynamoDB, SQS, …) attaches env vars to the pod spec and IAM policy statements to a generated pod-identity role. On registry-less clusters (Kubernetes.KubeConfig(...)) run pre-built image references and bind through environment variables.

Remote image on EKS (external — no Effect runtime in the container)

const cluster = yield* AWS.EKS.Cluster("Cluster", { compute: "auto" });
const nginx = yield* Kubernetes.Deployment("Nginx", {
cluster,
image: "nginx:1.27",
namespace: "default",
replicas: 3,
port: 80,
serviceType: "LoadBalancer",
});
nginx.url; // LB URL, e.g. "http://k8s-….elb.amazonaws.com"
nginx.deploymentName; // K8s-native attrs

Any cluster via kubeconfig

const local = Kubernetes.KubeConfig({ context: "kind-dev" });
const api = yield* Kubernetes.Deployment("Api", {
cluster: local,
image: "ghcr.io/acme/api:v3",
port: 8080,
serviceType: "ClusterIP",
});

Build your own Dockerfile

const legacy = yield* Kubernetes.Deployment("LegacyApp", {
cluster,
context: "./legacy",
replicas: 2,
port: 8080,
});

Inline Effect server with a DynamoDB binding (EKS)

const api = yield* Kubernetes.Deployment(
"Api",
{ cluster, main: import.meta.url, port: 3000, replicas: 2 },
Effect.gen(function* () {
const putItem = yield* AWS.DynamoDB.PutItem(table);
return {
fetch: Effect.gen(function* () {
yield* putItem({ Item: { id: { S: "1" } } });
return HttpServerResponse.text("ok");
}),
};
}).pipe(Effect.provide(AWS.DynamoDB.PutItemHttp)),
);

Tagged Effect server

export class Api extends Kubernetes.Deployment<Api, {
health: () => Effect.Effect<string>;
}>()("Api") {}
export default Api.make(
{ cluster, main: import.meta.url, port: 3000 },
Effect.gen(function* () {
return {
fetch: Effect.gen(function* () {
return HttpServerResponse.text("ok");
}),
health: () => Effect.succeed("ok"),
};
}),
);

main is bundled with rolldown at deploy time. Unused code is tree-shaken. effect, alchemy, and @distilled.cloud are marked pure so unused parts prune more aggressively. Your app is not marked pure.

Mark additional packages as pure

Only list packages with no top-level side effects.

{
main: import.meta.url,
build: {
pure: { packages: ["my-lib", "@my-scope/*"] },
},
}

Turn it off

{
main: import.meta.url,
build: { pure: false },
}
const tuned = yield* Kubernetes.Deployment("Api", {
cluster,
main: import.meta.url,
port: 3000,
podTemplate: {
spec: {
tolerations: [{ key: "gpu", operator: "Exists" }],
nodeSelector: { pool: "arm" },
},
},
});

Source: src/Kubernetes/Job.ts

Run-to-completion Kubernetes compute on any cluster — the Kubernetes analog of AWS.ECS.Task.

Job provisions a Kubernetes Job (or CronJob when schedule is set) via server-side apply and a ServiceAccount, plus — through the target cluster’s platform adapter — workload identity and a container image from exactly one of three sources flat on props: main (bundle an inline Effect program whose impl returns { run }), context (build your own Dockerfile), or image (a pre-built registry reference). On AWS.EKS.Cluster targets, bindings attach env vars to the pod and IAM policy statements to a generated pod-identity role, exactly like Kubernetes.Deployment.

Remote image (external — no Effect runtime in the container)

const migrate = yield* Kubernetes.Job("DbMigrate", {
cluster,
image: "ghcr.io/acme/migrator:v3",
backoffLimit: 2,
});

Inline Effect program with a DynamoDB binding (EKS)

const seed = yield* Kubernetes.Job(
"SeedData",
{ cluster, main: import.meta.url },
Effect.gen(function* () {
const putItem = yield* AWS.DynamoDB.PutItem(table);
return {
run: Effect.gen(function* () {
yield* putItem({ Item: { id: { S: "seed" } } });
}),
};
}).pipe(Effect.provide(AWS.DynamoDB.PutItemHttp)),
);

Tagged Effect program

export class Backfill extends Kubernetes.Job<Backfill, {
progress: () => Effect.Effect<number>;
}>()("Backfill") {}
export default Backfill.make(
{ cluster, main: import.meta.url, backoffLimit: 1 },
Effect.gen(function* () {
return {
run: Effect.gen(function* () { }),
progress: () => Effect.succeed(0),
};
}),
);

main is bundled with rolldown at deploy time. Unused code is tree-shaken. effect, alchemy, and @distilled.cloud are marked pure so unused parts prune more aggressively. Your app is not marked pure.

Mark additional packages as pure

Only list packages with no top-level side effects.

{
main: import.meta.url,
build: {
pure: { packages: ["my-lib", "@my-scope/*"] },
},
}

Turn it off

{
main: import.meta.url,
build: { pure: false },
}
const nightly = yield* Kubernetes.Job("NightlyBackfill", {
cluster,
main: import.meta.url,
schedule: "0 3 * * *",
});