Skip to content

Deployment

Source: src/AWS/EKS/Deployment.ts

A replicated Kubernetes server on Amazon EKS — the Kubernetes analog of AWS.ECS.Service.

Deployment provisions a Kubernetes Deployment + Service (+ ServiceAccount) via server-side apply, a pod-identity IAM role + PodIdentityAssociation, 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 registry reference, mirrored into ECR). 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 the pod-identity role, with credentials flowing through the EKS Pod Identity container-credentials chain.

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

const nginx = yield* AWS.EKS.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

Build your own Dockerfile

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

Inline Effect server with a DynamoDB binding

const api = yield* AWS.EKS.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 AWS.EKS.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"),
};
}),
);
const tuned = yield* AWS.EKS.Deployment("Api", {
cluster,
main: import.meta.url,
port: 3000,
podTemplate: {
spec: {
tolerations: [{ key: "gpu", operator: "Exists" }],
nodeSelector: { pool: "arm" },
},
},
});