--- title: EKS description: Stand up an EKS Auto Mode cluster on a Network and run containers on it — Deployments for servers, Jobs for run-to-completion work, Manifests for everything else. No YAML, no kubectl. --- import Tree from "../../../../components/diagrams/Tree.astro"; EKS is AWS's managed Kubernetes. AWS runs the Kubernetes control plane, and your containers run on it as Kubernetes objects. In **Auto Mode**, AWS also manages the nodes, their storage and their load balancers, so there are no machines to operate. Choose EKS when you want Kubernetes itself: Helm charts, operators, raw manifests, or a team that already runs on it. For containers without Kubernetes, [ECS](/aws/compute/ecs) has less to learn and less to pay for. ## Clusters, Pods, Deployments and Jobs A **cluster** is one Kubernetes installation: an API server and the **nodes** that run containers. A **Pod** is one or more containers scheduled together onto a node. A **Deployment** keeps a number of identical Pods running and replaces any that fail, and a **Service** gives them one stable address, public if it's a `LoadBalancer`. A **Job** runs a Pod until it finishes, and a **CronJob** runs one on a schedule. Every one of these is an object, described by a **manifest** and applied to the cluster. In Alchemy, `AWS.EKS.Cluster` creates the cluster from a VPC. The workloads come from `@alchemy.run/kubernetes`: `Kubernetes.Deployment` creates a Deployment and its Service, `Kubernetes.Job` a Job or CronJob, and `Kubernetes.Manifest` any other object. Each takes the cluster as its `cluster` prop, in the same program, with no YAML and no `kubectl`. The same workloads run on any cluster your kubeconfig reaches. The workload providers ship in `Kubernetes.providers()` — compose it with `AWS.providers()` in the Stack: ```typescript import * as AWS from "@alchemy.run/aws"; import * as Kubernetes from "@alchemy.run/kubernetes"; import * as Layer from "effect/Layer"; export default Alchemy.Stack( "my-app", { providers: Layer.mergeAll(AWS.providers(), Kubernetes.providers()), state: Alchemy.localState(), }, // ... ); ``` ## Create an Auto Mode cluster `compute: "auto"` turns on EKS Auto Mode with sensible defaults — managed compute (`system` and `general-purpose` node pools), block storage, elastic load balancing, and `API` authentication — and, when you don't pass `roleArn`, provisions and owns the cluster and node IAM roles with the standard Auto Mode managed policies: ```typescript // alchemy.run.ts import * as AWS from "@alchemy.run/aws"; const network = yield* AWS.EC2.Network("Network", { cidrBlock: "10.42.0.0/16", availabilityZones: 2, nat: "single", }); const cluster = yield* AWS.EKS.Cluster("Cluster", { compute: "auto", resourcesVpcConfig: { subnetIds: network.privateSubnetIds, endpointPublicAccess: true, endpointPrivateAccess: true, }, }); ``` The cluster lands in the network's private subnets, built on a [`Network`](/providers/aws/ec2/network). Budget for the create: an EKS control plane takes ~10 minutes to provision. ## Grant access and install add-ons Auto Mode provisions with `authenticationMode: "API"`, so cluster access is granted through [`AccessEntry`](/providers/aws/eks/accessentry) resources rather than the `aws-auth` ConfigMap, and [`Addon`](/providers/aws/eks/addon) installs EKS add-ons (EKS picks the default compatible version when you don't pin one): ```typescript const admin = yield* AWS.EKS.AccessEntry("ClusterAdmin", { clusterName: cluster.clusterName, principalArn: "arn:aws:iam::123456789012:role/YourAdminRole", accessPolicies: [ { policyArn: "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy", accessScope: { type: "cluster" }, }, ], }); const metricsServer = yield* AWS.EKS.Addon("MetricsServer", { clusterName: cluster.clusterName, addonName: "metrics-server", }); ``` The deploying principal is bootstrapped as cluster admin (`bootstrapClusterCreatorAdminPermissions: true` is part of the Auto Mode defaults), so these are for everyone (and everything) else that needs in. ## Deploy a server [`Kubernetes.Deployment`](/providers/kubernetes/deployment) is a replicated Kubernetes server — the Kubernetes analog of `AWS.ECS.Service`. It synthesizes a Kubernetes `Deployment` + `Service` (+ `ServiceAccount`) and applies them via server-side apply, with the container image coming from exactly one of three sources flat on props: `image` (a registry reference, mirrored into ECR), `context` (build your own Dockerfile), or `main` (bundle an inline Effect program). The simplest form runs a remote image with no Effect runtime in the container: ```typescript const echo = yield* Kubernetes.Deployment("EchoServer", { cluster, image: "registry.k8s.io/echoserver:1.10", namespace: "default", replicas: 2, port: 8080, serviceType: "LoadBalancer", }); echo.url; // LoadBalancer hostname (an NLB on Auto Mode) echo.deploymentName; // K8s-native attrs: deploymentName, serviceName, ... ``` `serviceType: "LoadBalancer"` provisions a cloud load balancer and exposes its hostname as `url`. Swap `image` for `context: "./legacy"` to build your own Dockerfile (`dockerfile` is a path, defaulting to `${context}/Dockerfile`). ## Effect servers with bindings Pass `main: import.meta.url` and a constructor Effect and the program is bundled into a generated image instead — the same authoring model as [Lambda](/aws/compute/lambda). Bindings work identically too: `Deployment` accepts the same `{ env, policyStatements }` binding contract as a Lambda `Function`, so every AWS `Binding.Service` attaches environment variables to the Pod spec and IAM policy statements to a generated **Pod Identity role**: ```typescript 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)), ); ``` Every Kubernetes workload on EKS gets Pod Identity as standard: Alchemy creates the IAM role, wires it to the workload's ServiceAccount with a [`PodIdentityAssociation`](/providers/aws/eks/podidentityassociation), and Pods resolve credentials through the EKS Pod Identity container-credentials chain — no OIDC provider or IRSA annotation ceremony. The tagged form (`class Api extends Kubernetes.Deployment()("Api") {}` + `Api.make(props, impl)`) works exactly as it does on Lambda and Cloudflare Workers. ## Run-to-completion work with Job [`Kubernetes.Job`](/providers/kubernetes/job) runs a container to completion — the Kubernetes analog of `AWS.ECS.Task`. Same three image sources, same bindings and Pod Identity; an Effect impl returns `{ run }` instead of `{ fetch }`, executing to completion inside the Pod: ```typescript const migrate = yield* Kubernetes.Job("DbMigrate", { cluster, image: "ghcr.io/acme/migrator:v3", backoffLimit: 2, }); ``` Set `schedule` (standard 5-field cron) and a Kubernetes `CronJob` is synthesized instead of a plain `Job`: ```typescript const nightly = yield* Kubernetes.Job("NightlyBackfill", { cluster, main: import.meta.url, schedule: "0 3 * * *", }); ``` ## Everything else is a Manifest [`Kubernetes.Manifest`](/providers/kubernetes/manifest) applies any raw Kubernetes object — StatefulSets, Namespaces, CRDs — via server-side apply. The manifest is a literal object, exactly as you would write it in YAML: ```typescript const namespace = yield* Kubernetes.Manifest("DemoNamespace", { cluster, manifest: { apiVersion: "v1", kind: "Namespace", metadata: { name: "demo" }, }, }); ``` There is no kubeconfig step: Alchemy authenticates to the cluster's API with your AWS credentials (a presigned STS token) and applies objects via **server-side apply** under the `alchemy` field manager, so deploys converge the live objects the same way the rest of your Stack converges cloud resources. Unknown kinds resolve through the Kubernetes API discovery endpoint, so CRDs work without any registration. ## Install a Helm chart [`Kubernetes.HelmChart`](/providers/kubernetes/helmchart) renders a chart with the local `helm` CLI (`helm template` — install helm on your machine, like Docker for image builds) and applies the rendered objects through the same server-side-apply path as `Manifest`: ```typescript const ingress = yield* Kubernetes.HelmChart("IngressNginx", { cluster, chart: "ingress-nginx", repo: "https://kubernetes.github.io/ingress-nginx", version: "4.11.2", namespace: "ingress-nginx", createNamespace: true, values: { controller: { replicaCount: 2 }, }, }); ``` `chart` also accepts `oci://` references and local chart directories, and `values` is a literal object — the same shape as a `values.yaml` file. Because the objects are applied (not `helm install`ed), Alchemy owns their lifecycle: the full render is re-applied whenever the chart's inputs change, objects that drop out of the render are pruned, and destroy deletes them — there is no in-cluster Helm release record. Charts that rely on install/upgrade hooks for correctness should be installed with Helm directly. ## What EKS adds to Kubernetes workloads The `Kubernetes.*` resources are cluster-agnostic. When their `cluster` is an EKS cluster, `AWS.providers()` contributes an adapter that handles the AWS-specific parts. ### Authentication Alchemy signs a short-lived bearer token with your AWS credentials for every request, so there is no kubeconfig to manage. It's the same token `aws eks get-token` produces. The principal that created the cluster is its admin. Grant anyone else access with [`AccessEntry`](/providers/aws/eks/accessentry). ### Images in ECR Each `Deployment` and `Job` gets its own private ECR repository. `main` programs are bundled and built into an image, `context` Dockerfiles are built, and `image` references are pulled and pushed into the repository, so pods only pull from your account. Set `architecture: "arm64"` for Graviton nodes. The default builds `amd64`. The repository is deleted when the workload is destroyed. ### Pod Identity Each workload gets an IAM role and a [`PodIdentityAssociation`](/providers/aws/eks/podidentityassociation) for its ServiceAccount. AWS bindings used by the workload add their IAM statements to that role, and the pod receives temporary credentials for it through the EKS Pod Identity agent. Attach AWS-managed or customer-managed policies with `identity.managedPolicyArns`: ```typescript const exporter = yield* Kubernetes.Job("Export", { cluster, main: import.meta.url, identity: { managedPolicyArns: ["arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"], }, }); ``` ### Load balancers Auto Mode's built-in load balancer controller only handles Services with `loadBalancerClass: eks.amazonaws.com/nlb`, and creates internal load balancers by default. On `LoadBalancer` Services Alchemy sets that class (when the cluster has Auto Mode load balancing enabled) and the `service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing` annotation, so `url` is reachable from the internet. Your own `serviceAnnotations` take precedence. Set the scheme to `internal` to keep a service private: ```typescript const internal = yield* Kubernetes.Deployment("Internal", { cluster, image: "ghcr.io/acme/internal:v1", port: 8080, serviceAnnotations: { "service.beta.kubernetes.io/aws-load-balancer-scheme": "internal", }, }); ``` ### Cleanup The ECR repository and Pod Identity role outlive the cluster's own objects. On destroy Alchemy deletes the in-cluster objects if the cluster is still reachable, then deletes the repository and role whether or not the cluster still exists, so destroying a cluster and its workloads together leaves nothing behind in AWS. ## Run each pod in its own VM Pods on the same node share its kernel. To run code you don't trust, give each pod its own [Nitro Sandbox](/aws/compute/nitro-sandboxes): a lightweight VM that the Nitro hypervisor isolates from the node and from every other pod on it. Set `runtimeClassName` on a Deployment or a Job: ```typescript title="alchemy.run.ts" const agent = yield* Kubernetes.Deployment("Agent", { cluster, image: "ghcr.io/acme/agent:1", port: 8080, runtimeClassName: "isolated-sandbox", }); ``` On Auto Mode, that's all it takes. Auto Mode provides the `isolated-sandbox` and `confidential-sandbox` RuntimeClasses, launches a node type that supports sandboxes, and starts each pod in its own. Sandboxes need Kubernetes 1.36 or later, so set `version` on an older cluster. Containers in one pod share its sandbox. `isolated-sandbox` protects the node and other pods from what runs inside, and keeps `kubectl exec` and logs working. `confidential-sandbox` also hides the pod's memory from the node, and needs a policy that pins its images and arguments. See [Isolated or confidential](/aws/compute/nitro-sandboxes#isolated-or-confidential). For code that must not reach the network at all, add the `network-isolated` annotation through `podTemplate`. The sandbox then boots with no network device: ```typescript title="alchemy.run.ts" yield* Kubernetes.Job("RunGeneratedCode", { cluster, image: "ghcr.io/acme/runner:1", runtimeClassName: "isolated-sandbox", podTemplate: { metadata: { annotations: { "sandbox.amazonaws.com/network-isolated": "true" } }, }, }); ``` A network-isolated pod can't serve traffic or pass HTTP probes, so it suits Jobs better than Deployments. Outside Auto Mode, nodes need an AMI with the Nitro Sandbox runtime and Nitro Enclaves turned on in their launch template, with `enclaveOptions: { enabled: true }` on [`AWS.AutoScaling.LaunchTemplate`](/providers/aws/autoscaling#launchtemplate). See [Run a pod in isolated mode](https://docs.aws.amazon.com/eks/latest/userguide/sandboxing-isolated-setup.html). ## Target an EKS cluster you don't manage To deploy onto a cluster created elsewhere, name it in a connection. The adapter looks up the endpoint and certificate authority from the cluster name: ```typescript const cluster: Kubernetes.Connection = { auth: { kind: "aws-eks", clusterName: "shared-prod", region: "us-west-2" }, }; ``` `region` defaults to the Stack's AWS region. The `aws-eks` auth kind is added to the `Kubernetes.Connection` type by importing `@alchemy.run/aws`, and it requires `AWS.providers()` in the Stack. Your AWS principal needs an access entry on the cluster. Workloads get the same ECR, Pod Identity, and load balancer behavior as on a Stack-managed cluster. ## Run on SageMaker HyperPod An EKS cluster can also orchestrate a [SageMaker HyperPod](/aws/compute/hyperpod) fleet — persistent, health-checked ML compute whose nodes join the cluster as ordinary Kubernetes nodes. [`AWS.SageMaker.Cluster`](/providers/aws/sagemaker/cluster) attaches the fleet to the EKS control plane: ```typescript const hyperpod = yield* AWS.SageMaker.Cluster("HyperPod", { orchestrator: { Eks: { ClusterArn: cluster.clusterArn } }, vpcConfig: { SecurityGroupIds: [clusterSecurityGroupId], Subnets: network.privateSubnetIds, }, instanceGroups: { workers: { InstanceType: "ml.g5.xlarge", InstanceCount: 4, ExecutionRole: role.roleArn, LifeCycleConfig: { SourceS3Uri: script.sourceS3Uri, OnCreate: script.onCreate, }, }, }, }); ``` `Kubernetes.Deployment` and `Kubernetes.Job` then opt onto those nodes in plain Kubernetes vocabulary — the HyperPod resources expose the derived values as attributes. The instance-group keys carry through to the cluster's attributes as types — `hyperpod.instanceGroups.workers` is typed per key and a typo'd name is a compile error — so the workload is connected to the fleet through the resource graph, and a team's `ComputeQuota` materializes the governed namespace and Kueue queue: ```typescript const train = yield* Kubernetes.Job("Train", { cluster, main: import.meta.url, namespace: researchQuota.namespace, // hyperpod-ns-research labels: { [AWS.SageMaker.KUEUE_QUEUE_NAME_LABEL]: researchQuota.queueName, [AWS.SageMaker.KUEUE_PRIORITY_CLASS_LABEL]: "training-priority", }, podTemplate: { spec: { nodeSelector: hyperpod.instanceGroups.workers.nodeSelector }, }, }); ``` See [HyperPod](/aws/compute/hyperpod) for the fleet's prerequisites (lifecycle scripts, the dependencies Helm chart, EKS auth-mode and version constraints) and the full governance surface. ## Where next - [Kubernetes](/kubernetes) — the full guide to `Kubernetes.*` workloads, manifests, and Helm charts, with a [tutorial](/kubernetes/tutorial/part-1) you can run on a local cluster before deploying to EKS. - [VPC & networking](/aws/networking) — what the `Network` helper builds under the cluster. - [Nitro Sandboxes](/aws/compute/nitro-sandboxes) — the same VM isolation on ECS and EC2. - [HyperPod](/aws/compute/hyperpod) — run training fleets on this cluster's nodes. - [Choosing a runtime](/aws/compute/choosing-a-runtime) — when Lambda or ECS is the better fit than running your own Kubernetes workloads. - [`Cluster` reference](/providers/aws/eks/cluster), [`Deployment` reference](/providers/kubernetes/deployment), [`Job` reference](/providers/kubernetes/job), [`Manifest` reference](/providers/kubernetes/manifest) — every prop and attribute.