Deploying a Mule Application on AWS EKS: A Step-by-Step Guide

Deploying a Mule Application on AWS EKS: A Step-by-Step Guide
Deploying a Mule Application on AWS EKS: A Step-by-Step Guide

Introduction 

As businesses increasingly adopt cloud-native solutions, deploying Mule applications on Kubernetes has become a popular choice for scalability, flexibility, and resilience. Amazon Elastic Kubernetes Service (EKS) simplifies Kubernetes management, allowing developers to focus on deploying and scaling their applications efficiently.

In this blog, we will walk you through the process of deploying a MuleSoft application on AWS EKS, covering essential configurations, best practices, and deployment strategies. Whether you're a beginner exploring cloud-based Mule deployments or an experienced developer looking to optimize your workflow, this guide will help you set up a robust and scalable integration solution on AWS. 

Prerequisites 

Before deploying a Mule application on AWS EKS, ensure you have the following prerequisites in place: 

  1. AWS Account – A valid AWS account with necessary permissions to create and manage EKS clusters. 
  2. MuleSoft Application – A packaged Mule application (.jar or .zip) ready for deployment. 
  3. Docker Installed – To containerize the Mule application before deployment.(Docker Install
  4. IAM Roles & Permissions – Proper roles assigned for EKS access, including worker nodes and Kubernetes permissions. 

Step-by-Step Guide: Creating an Amazon EKS Cluster via AWS Console 

Step 1: Log in to AWS Console 

  1. Go to the AWS Management ConsoleAWS Console 
  2. Search for EKS in the AWS services search bar. 
  3. Click Amazon Elastic Kubernetes Service (EKS)

Step 2: Create an EKS Cluster. 

  • Click Create Cluster
  • Select Quick Configuration(with EKS auto mode) 
  • Cluster name: Enter a unique name (e.g., mule-eks-cluster). 
  • Kubernetes version: Choose the latest stable version. 
  • Cluster IAM Role: Click on Create recommended role if no IAM role is available. 
  • Select AWS service in trusted Entity Type and EKS Cluster in Use case & necessary permission then Click next. 
  • Review name and permission and Click Create role. 
  • Add the newly created Cluster IAM Role. 
  • Node IAM Role: Click on Create recommended role if no IAM role is available. 
  • Select AWS service in trusted Entity Type and EC2 in Use case & necessary permission then Click next. 
  • Review name and permission. Click Create role. 
  • In this quick configuration method default VPC and subnets are automatically available. So, Click create role and the cluster will be created.

Step 2: Create a Docker Image for Mule runtime. 

  • Install Docker Desktop and Check the version (docker --version). 
  • Create a Folder and add Dockerfile  with necessary set of instructions to build docker image and add a mule standalone zip file. 
Docker file
  • Open powershell as an administrator. 
  • Create an image with the below command. 

docker build -t <image name> -f Dockerfile .  

  • Check the image is created with (docker images *
  • Use the following command to run a container from the Docker image. 

docker run -d --name <container name> -p 8081:8081 -p 9999:9999 <image name> 

  • Login into the docker hub. (docker login
  • Now tag and push the image to the repository with the commands below. 

docker tag <image name> your-dockerhub-username/<image name>:lates

docker push your-dockerhub-username/<image name>:latest  

  • Create your docker hub secret with the commands below. 

kubectl create secret docker-registry my-dockerhub-secret ` 

  --docker-username=<your docker username> ` 

  --docker-password=<your docker password> ` 

  --docker-email=<your docker email> 

Step 3: Create a Pod in EKS. 

  • Open the Cloudshell in AWS console by clicking on the shell icon in the top right corner. 
AWS Cloudshell
  • Create a YAML file for the deployment with necessary requirements. 
Deployment.yaml
  • Similarly create the YAML file for amc configuration, services, volume, storage class. 
service.yaml
amc-configmap.yaml
storageclass.yaml
volume.yaml
  • Upload all the files in the cloudshell by clicking on the Actions button in the top right corner of the cloudshell. 
  • Apply all the files with command mentioned below. 

kubectl apply -f <filename> 

  • Once every file is created, check the pods are created and running successfully by using the command. 

kubectl get pods  

Pod Status

Step 4: Set up a server in Mule and configure it with the EKS pod. 

  • Log into your anypoint platform and go to runtime manager. 
  • Choose any env and go to server tab. 
  • Click on Add server and give a name to the server. 
  • Now copy the command shown. 
Add server in Anypoint platform
  • Now Go to cloudshell in aws.  
  • Get into the pod we created by using the command below 

Kubectl exec –it <pod name> -- /bin/sh  

  • Go to the mule directory with help of the command below 

cd /opt/mule/bin 

  • Now run the command we copied from the anypoint platform. The server will be created. 
  • Then stop and start the mule runtime in the pod, to move the server into running status in anypoint platform with below commands under the same directory. 

./mule stop 

./mule start   

  • Now the server will be in running mode in anypoint platform 
Server Created in Anypoint Platform

Step 5: Deploy an application under the server in Anypoint platform. 

  • Go to runtime manager and choose the env where we created the server. 
  • Go to application tab and click deploy application tab. 
  • In the deploy application tab, provide the application name. Under the deployment target click on Hybrid and select your server. 
Deploy mule application under the server
  • Add the application file and click on deploy. 
  • Now go to the server tab and click on the server we created, We can see the application deployed under the server. 
Application Deployed

Conclusion 

In this guide, we have covered the step-by-step process of deploying a Mule application on AWS EKS, from setting up the cluster to configuring the necessary components for seamless integration. By leveraging EKS, you can ensure scalability, high availability, and efficient management of your Mule applications in a Kubernetes-based infrastructure. With proper configuration and best practices, your deployment will be optimized for performance and reliability, enabling smooth API management and service orchestration in the cloud. 

Mulecraft Footer