EMR on EKS
EMR on EKS provides an AWS-shaped control plane for Spark workloads that target EKS virtual clusters. It records virtual clusters and job runs, accepts the related templates and endpoint resources, and can either emulate state changes or run Spark drivers in containers.
Service model
The service groups its API around a virtual cluster. A virtual cluster names an EKS cluster and namespace, while job runs use that relationship as their execution target.
Virtual clusters
A virtual cluster is the control-plane link between EMR on EKS and an EKS cluster. It starts in RUNNING and becomes TERMINATED when deleted. Its scheduler settings are visible through the API and can limit concurrent runs or queue new submissions.
The container provider identifies the EKS cluster. The service uses that identity when it checks whether a submitted job can proceed. A virtual cluster also records optional security, session, scheduler, and tag settings for later API reads.
References: src/…/EmrContainersService.java• L331-439 src/…/EmrContainersService.java• L1611-1649
Job runs
A job run is the durable record of one Spark submission. StartJobRun accepts a direct job definition or fills missing execution data from a job template. The service keeps the job driver, release label, role, configuration, creator, tags, retry policy, and state in the job-run view.
The runner mode determines the execution model. Immediate mode advances a valid run to COMPLETED at once or after a configured duration. Docker mode starts the Spark driver in a container and changes the run through SUBMITTED, RUNNING, and a terminal state based on the driver outcome.
References: src/…/EmrContainersService.java• L444-548 src/…/EmrContainersService.java• L1383-1479 src/…/EmrContainersService.java• L1568-1605
Supporting resources
Job templates hold reusable job data and parameter rules. Security configurations hold reusable security data. Managed endpoints represent interactive access points on a virtual cluster and can issue short-lived session credentials.
In Docker mode, a managed endpoint starts a Jupyter Enterprise Gateway in a Spark notebook container. The endpoint exposes a server URL through the emulator, while the gateway provides Python and PySpark kernel access. These resources support the control plane around a job run and interactive work through the same container runner.
References: src/…/EmrContainersService.java• L594-680 src/…/EmrContainersService.java• L725-759 src/…/EmrContainersGateways.java• L19-35
Request interface
The API uses REST JSON routes for the emr-containers credential scope. Public operation paths are mapped from the AWS service model and handled by the EMR on EKS controller.
Request routing
The route catalog maps each EMR on EKS action to its HTTP method and path. The controller accepts virtual-cluster, job-run, endpoint, template, security-configuration, and tag operations under those paths.
Some EMR on EKS paths are literal top-level paths such as /virtualclusters and /jobtemplates. A pre-routing filter moves only requests signed for emr-containers to the service's internal route space. This prevents another service with similar path patterns from receiving the request.
Managed endpoint traffic uses a separate endpoint path. The gateway proxy checks the endpoint session token before it forwards HTTP traffic or a WebSocket upgrade to the endpoint's gateway. It removes the token from the forwarded request and preserves the gateway's response shape.
See request routing and protocols for the shared request path and signing model.
References: src/…/rest-routes.json• L653-681 src/…/EmrContainersRouteFilter.java• L14-40 src/…/EmrContainersController.java• L24-43 src/…/EmrContainersGatewayProxy.java• L80-116 src/…/EmrContainersGatewayProxy.java• L163-301
Request validation
Every operation checks its body, path-bound values, and query values against the generated EMR on EKS request shapes. Invalid JSON objects, member types, required fields, ranges, patterns, and enum values return ValidationException before the resource changes.
The same request scope also applies account and Region identity to resource ARNs. A resource in another Region is not treated as a local resource.
References: src/…/EmrContainersRequestShapes.java• L6-21 src/…/EmrContainersController.java• L210-234 src/…/EmrContainersService.java• L1014-1035
Job execution lifecycle
The emulated lifecycle turns a valid API submission into a state record. It checks the target virtual cluster and its EKS provider before it either advances the record in place or starts a containerized Spark driver.
This diagram shows how a client submission becomes a terminal job-run state.
flowchart LR
A[Create or select virtual cluster] --> B[StartJobRun]
B --> C{Virtual cluster is RUNNING}
C -->|No| D[Return validation error]
C -->|Yes| E[Resolve direct data or template]
E --> F{Referenced EKS cluster exists}
F -->|No| G[Store FAILED run]
F -->|Yes| H{Scheduler slot available}
H -->|No| I[Store PENDING run]
I --> J{Slot frees before queue timeout}
J -->|No| K[Store FAILED run]
J -->|Yes| L[Start run]
H -->|Yes| L
L --> M{Runner mode}
M -->|Immediate| N[Store COMPLETED or delayed completion]
M -->|Docker| O[Store SUBMITTED and start driver]
O --> P[Store RUNNING when driver starts]
P --> Q{Driver outcome}
Q -->|Success| R[Store COMPLETED]
Q -->|Failure with retry left| S[Wait for retry backoff]
S --> O
Q -->|Failure or cancellation| T[Store FAILED or CANCELLED]
Submission outcomes
StartJobRun rejects a missing or terminated virtual cluster. It then resolves template values and checks the execution role, release label, and job driver. If the EKS cluster named by the container provider is absent in the request account and Region, the run is stored as FAILED with CLUSTER_UNAVAILABLE.
If the provider exists, scheduler limits decide whether the run starts or waits in the virtual-cluster queue. Immediate mode completes the run at once or after the configured duration. Docker mode records SUBMITTED until the driver starts, then records COMPLETED, FAILED, or CANCELLED; reads and list operations also settle queued and time-based records.
References: src/…/EmrContainersService.java• L444-548 src/…/EmrContainersService.java• L1276-1403 src/…/EmrContainersService.java• L1568-1605
Template resolution
A job template supplies missing execution fields and can define named parameters. Request values take priority over template defaults. A required parameter without a value or a non-numeric value for a NUMBER parameter stops submission with ValidationException.
The resolved template data becomes part of the job-run record. An undeclared placeholder remains unchanged, which lets clients use template text that is not part of the parameter map.
References: src/…/EmrContainersService.java• L459-476 src/…/EmrContainersService.java• L1214-1272
Containerized Spark execution
Docker mode maps a job driver's Spark submit or Spark SQL definition to a container based on the release label. Configuration overrides provide Spark defaults, driver settings, archives, and monitoring targets. The driver and its executors run through the local container runner rather than through an EKS pod scheduler.
The service reports driver start and exit back to the job-run state machine. A successful exit completes the run. A non-zero exit fails it or starts the next retry after an increasing backoff. S3 and CloudWatch monitoring settings determine where driver output is recorded.
References: src/…/EmrContainersSparkJobs.java• L19-27 src/…/EmrContainersSparkJobs.java• L61-137 src/…/EmrContainersSparkJobs.java• L140-177 src/…/EmrContainersService.java• L1492-1605
Managed endpoint execution
Docker mode also uses a container to host each managed endpoint's Jupyter Enterprise Gateway. The endpoint starts in CREATING, becomes ACTIVE after the gateway answers, and exposes a server URL that the proxy serves.
Clients first request session credentials. The proxy accepts the matching token in the query or authorization header. It forwards ordinary HTTP requests as streams and joins WebSocket connections for kernel traffic. An endpoint that does not start, stops unexpectedly, or loses its gateway becomes TERMINATED_WITH_ERRORS; deletion waits for the gateway to stop before it becomes TERMINATED.
References: src/…/EmrContainersService.java• L646-759 src/…/EmrContainersService.java• L776-905 src/…/EmrContainersGateways.java• L141-197 src/…/EmrContainersGatewayProxy.java• L36-45
Tag handling
Tags provide resource metadata across the virtual cluster, job-run, and managed-endpoint lifecycles. The service accepts tags at resource creation and exposes shared tag operations by resource ARN.
Taggable resources
TagResource, UntagResource, and ListTagsForResource accept ARNs for virtual clusters, their job runs, and their managed endpoints. Job templates and security configurations keep creation-time tags but are not targets of the shared tag API.
Only active resources accept tag changes. Terminated virtual clusters, finished job runs, and terminated endpoints reject updates. A resource can hold at most 50 tags, and tag values must be JSON strings.
References: src/…/EmrContainersService.java• L967-1001 src/…/EmrContainersService.java• L1168-1211 src/…/EmrContainersTagHandler.java• L10-60
Job-run tag inheritance
When a job run uses a template, the template's jobTags form the base tag set. Tags in the StartJobRun request replace matching keys and add new keys. The combined set must remain within the 50-tag limit before the run is stored.
The tag handler keeps EMR on EKS wire behavior distinct from services that use the shared tag path. Its tag operations return HTTP 200, and strict validation prevents non-string tag values from being coerced.
References: src/…/EmrContainersService.java• L496-501 src/…/EmrContainersService.java• L974-1001 src/…/EmrContainersTagHandler.java• L31-47
Related systems
EMR on EKS uses EKS as the named container provider but remains a separate control plane. It checks EKS cluster identity for job outcomes while Docker mode runs Spark and endpoint gateway containers through the local container runner.
The broader EKS and container runtime model is described in ECS and EKS container orchestration. That page explains the EKS cluster records and local runtime boundary that EMR on EKS references.
Change checklist
When these files or sections are changed, remember to consider these:
- If an operation path or credential scope changes, keep the route catalog, signed-path filter, controller path, gateway path, and AWS client behavior aligned.
- If virtual-cluster or EKS provider rules change, keep cluster lookup, Region and account scoping, scheduler limits, queue settlement, job failure state, and access-entry integration reporting aligned.
- If job-run fields or states change, keep direct submissions, template resolution, delayed advancement, container callbacks, retry handling, cancellation, list filters, and response views aligned.
- If Docker job construction changes, keep release-image mapping, Spark driver selection, configuration overrides, monitoring paths, execution-role credentials, and runner outcomes aligned.
- If managed endpoint behavior changes, keep gateway startup state, server URLs, session-token grants, proxy routing, WebSocket upgrades, and termination outcomes aligned.
- If tag rules change, keep creation tags, template tag inheritance, ARN resource matching, active-state checks, the 50-tag limit, and strict wire validation aligned.
- If request constraints change, regenerate the vendored shapes and keep path, query, and body validation consistent.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A request is not signed for emr-containers on an EMR path | The request is not moved to the EMR on EKS controller | Preserve service-specific route matching and credential scope |
| A job names a missing or cross-Region EKS cluster | The run is stored as FAILED with CLUSTER_UNAVAILABLE | Create the provider in the same account and Region before submission |
| A job targets a terminated virtual cluster | Submission returns ValidationException and no run is created | Use a RUNNING virtual cluster |
| A scheduler queue is full or a run waits for 30 minutes | Submission is rejected or the queued run becomes FAILED | Set suitable concurrency and queue limits |
| A template parameter has no value or has the wrong number format | StartJobRun returns ValidationException | Supply each required parameter with a valid value |
| A Docker job has no usable entry point | The run becomes FAILED with VALIDATION_ERROR | Provide a Spark submit or Spark SQL entry point |
| A Spark driver exits with a non-zero code | The run becomes FAILED or waits for its retry backoff | Set a valid retry policy and inspect driver logs |
| A managed endpoint gateway does not answer or stops unexpectedly | The endpoint becomes TERMINATED_WITH_ERRORS and its server URL is removed | Keep the configured container image and runtime available |
| A gateway request has no valid endpoint token or targets a non-active endpoint | The proxy returns 401 or 503 instead of forwarding the request | Request session credentials and use them before expiry |
| A tag update targets a finished resource | The tag operation returns ValidationException | Update tags while the resource is active |
| Template and request tags exceed 50 entries | The job run is rejected | Check the merged tag set before submission |
| A client expects EKS pod execution in immediate mode | The API record changes state but no workload runs | Use Docker mode for emulated container execution |
Key files
| File | Why to read it |
|---|---|
| src/…/EmrContainersService.java | Defines virtual clusters, job runs, scheduler behavior, endpoint state, retries, and tag rules |
| src/…/EmrContainersSparkJobs.java | Maps EMR on EKS Spark drivers and monitoring settings to container jobs |
| src/…/EmrContainersGateways.java | Defines the containerized interactive gateway and its kernel behavior |
| src/…/EmrContainersGatewayProxy.java | Shows session-token checks and HTTP or WebSocket forwarding to endpoint gateways |
| src/…/EmrContainersController.java | Shows the REST JSON operation surface and path-to-service mapping |
| src/…/EmrContainersRouteFilter.java | Shows how signed EMR on EKS paths reach the internal controller without colliding with other services |
| src/…/EmrContainersTagHandler.java | Defines shared tag-route behavior and strict tag response rules |
| src/…/EmrContainersRequestShapes.java | Connects API requests to the generated EMR on EKS validation constraints |
| src/…/rest-routes.json | Defines the public HTTP method and path for each EMR on EKS action |
| src/…/emr-containers-request-shapes.json | Provides the AWS-shaped request constraints used by the service |