|
| 1 | +## EKS Cluster w/ Amazon Manged Workflows for Apache Airflopw (MWAA) |
| 2 | + |
| 3 | +The example demonstrates how to use Amazon Managed Workflows for Apache Airflow (MWAA) with Amazon EKS. |
| 4 | + |
| 5 | +This example was originated from the steps provided on MWAA documentation on the link below: |
| 6 | +[mwaa-eks-example](https://docs.aws.amazon.com/mwaa/latest/userguide/mwaa-eks-example.html) |
| 7 | + |
| 8 | +### Considerations |
| 9 | + |
| 10 | +1. Ideally we recommend adding the steps to sync requirements/sync dags to the MWAA S3 Bucket as part of a CI/CD pipeline. Generally Dags development have a different lifecycle than the Terraform code to provision infrastructure. |
| 11 | +However for simplicity we are providing steps for that using Terraform running AWS CLI commands on null_resource. |
| 12 | + |
| 13 | +## Prerequisites: |
| 14 | + |
| 15 | +Ensure that you have the following tools installed locally: |
| 16 | + |
| 17 | +1. [aws cli](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) |
| 18 | +2. [kubectl](https://Kubernetes.io/docs/tasks/tools/) |
| 19 | +3. [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) |
| 20 | + |
| 21 | +## Deploy |
| 22 | + |
| 23 | +To provision this example: |
| 24 | + |
| 25 | +```sh |
| 26 | +terraform init |
| 27 | +terraform apply |
| 28 | +``` |
| 29 | + |
| 30 | +Enter `yes` at command prompt to apply |
| 31 | + |
| 32 | + |
| 33 | +## Validate |
| 34 | + |
| 35 | +The following command will update the `kubeconfig` on your local machine and allow you to interact with your EKS Cluster using `kubectl` to validate the deployment. |
| 36 | + |
| 37 | +1. Run `update-kubeconfig` command: |
| 38 | + |
| 39 | +```sh |
| 40 | +aws eks --region <REGION> update-kubeconfig --name <CLUSTER_NAME> |
| 41 | +``` |
| 42 | + |
| 43 | +2. List the nodes running currently |
| 44 | + |
| 45 | +```sh |
| 46 | +kubectl get nodes |
| 47 | + |
| 48 | +# Output should look like below |
| 49 | +NAME STATUS ROLES AGE VERSION |
| 50 | +ip-10-0-30-125.us-west-2.compute.internal Ready <none> 2m19s v1.22.9-eks-810597c |
| 51 | +``` |
| 52 | + |
| 53 | +3. Log into Apache Airflow UI |
| 54 | + |
| 55 | +- Open the Environments page on the Amazon MWAA console |
| 56 | +- Choose an environment |
| 57 | +- Under the `Details` section, click the link for the Airflow UI |
| 58 | + |
| 59 | +4. Triger the DAG workflow to execute |
| 60 | + |
| 61 | +In the Airflow UI, enable the example and then trigger it. |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +5. Verify that the pod was executed successfully |
| 68 | + |
| 69 | +After it runs and completes successfully, use the following command to verify the pod: |
| 70 | + |
| 71 | +```sh |
| 72 | +kubectl get pods -n mwaa |
| 73 | +``` |
| 74 | + |
| 75 | +You should see output similar to the following: |
| 76 | + |
| 77 | +```sh |
| 78 | +NAME READY STATUS RESTARTS AGE |
| 79 | +mwaa-pod-test.4bed823d645844bc8e6899fd858f119d 0/1 Completed 0 25s |
| 80 | +``` |
| 81 | + |
| 82 | +## Destroy |
| 83 | + |
| 84 | +To teardown and remove the resources created in this example: |
| 85 | + |
| 86 | +```sh |
| 87 | +terraform destroy -auto-approve |
| 88 | +``` |
0 commit comments