Amazon EMR on Amazon EKS

Amazon EMR on EKS provides a deployment option for Amazon EMR that allows you to run open-source big data frameworks on Amazon EKS.

Prerequisite Tasks

To use these operators, you must do a few things:


Submit a job to an Amazon EMR virtual cluster


This example assumes that you already have an EMR on EKS virtual cluster configured. See the EMR on EKS Getting Started guide for more information.

The EmrContainerOperator will submit a new job to an Amazon EMR on Amazon EKS virtual cluster The example job below calculates the mathematical constant Pi. In a production job, you would usually refer to a Spark script on Amazon Simple Storage Service (S3).

To create a job for Amazon EMR on Amazon EKS, you need to specify your virtual cluster ID, the release of Amazon EMR you want to use, your IAM execution role, and Spark submit parameters.

You can also optionally provide configuration overrides such as Spark, Hive, or Log4j properties as well as monitoring configuration that sends Spark logs to Amazon S3 or Amazon Cloudwatch.

In the example, we show how to add an applicationConfiguration to use the AWS Glue data catalog and monitoringConfiguration to send logs to the /aws/emr-eks-spark log group in Amazon CloudWatch. Refer to the EMR on EKS guide for more details on job configuration.


    "sparkSubmitJobDriver": {
        "entryPoint": "local:///usr/lib/spark/examples/src/main/python/",
        "sparkSubmitParameters": "--conf spark.executors.instances=2 --conf spark.executors.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1",  # noqa: E501

    "applicationConfiguration": [
            "classification": "spark-defaults",
            "properties": {
                "spark.hadoop.hive.metastore.client.factory.class": "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory",  # noqa: E501
    "monitoringConfiguration": {
        "cloudWatchMonitoringConfiguration": {
            "logGroupName": "/aws/emr-eks-spark",
            "logStreamNamePrefix": "airflow",

We pass the virtual_cluster_id and execution_role_arn values as operator parameters, but you can store them in a connection or provide them in the DAG. Your AWS region should be defined either in the aws_default connection as {"region_name": "us-east-1"} or a custom connection name that gets passed to the operator with the aws_conn_id parameter. The operator returns the Job ID of the job run.


job_starter = EmrContainerOperator(


Wait on an Amazon EMR virtual cluster job

To wait on the status of an Amazon EMR virtual cluster job to reach a terminal state, you can use EmrContainerSensor


job_waiter = EmrContainerSensor(
    task_id="job_waiter", virtual_cluster_id=VIRTUAL_CLUSTER_ID, job_id=str(job_starter.output)

Was this entry helpful?