Job
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.
Creating a Job
Section titled “Creating a Job”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), }; }),);Bundling & Tree-shaking
Section titled “Bundling & Tree-shaking”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 },}Scheduling
Section titled “Scheduling”const nightly = yield* Kubernetes.Job("NightlyBackfill", { cluster, main: import.meta.url, schedule: "0 3 * * *",});