Mule on Kubernetes

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Kubernetes which is also known as K8 is a well-known container management solution. The main advantage of
Kubernetes is it is open source and production ready. The other advantage is when there are multiple instances or deployments happens, it becomes very difficult to manage them manually and it requires great tools like Kubernetes.

This blog will demonstrate an easy way to run Kubernetes on Windows machine and deploy a Mule runtime on Kubernetes.

To start with, we need  Minikube , which is a tool that makes it easy to run Kubernetes locally.  The very first thing we need to do is to download  minikube-windows-amd64  form GitHub . Then it needs to be renamed as minikube.exe.

We also need kubectl.exe from here, which controls the Kubernetes cluster manager and put it on the same path.

Getting Started:

So, we are ready to start. We will get into command prompt and run the following:
minikube start and will get the following:

m1

So Kubernetes is ready to bang on our system!

We can now run the following command to test the status:
minikube status and will get the following:

m2

Which shows minikube is ready and running, kubectl is also configured!

We can get the IP address of the cluster using ip command  minikube ip:

m3

As we can see 192.168.99.100 is the virtual host where Kubernetes is running. We will use this while testing our deployed services once we deploy and expose our deployment.

We can start the dashboard which is a web console using minikube dashboard as following:

m4

The dashboard will open right as follows in the browser:

m5

We can check the current deployment using kubectl get deployments which will display No resource found. as there is no deployment we did:

m6

Let’s create a new deployment from the console dashboard by clicking create on top right:

m7

We will fill the App-name as test-mule-app and pull a docker image from docker hub, this time let’s take a Mule docker image and pull it from there. If we go to docker hub, we can see a Mule runtime docker image is already there which we will now pull on our docker container of Kubernetes.

Now, if we pull this image to run on Kubernetes, we can see the image has a sample Mule application that runs on HTTP port 9082 which we can test on our Kubernetes after deployment:

m8

So, now let’s start to configure our application for deployment in Kubernetes as follows:

m9

Here if we see above image, we can see the configuration details. We are providing App-name as test-mule-app, Container-image name as anir37/anirban-mule, Number of pods let be 1 and Port and Target port be 9082 and finally, we click Deploy.

Once the deployment starts we can see the deployment name in the Dashboard under Deployments:

m10

Now, if we run the kubectl get deployments command again in the console, we will get the deployment list there:

m11

In our Dashboard, we check the logs, we will find the Mule runtime is deployed and running successfully in the container as we can see below:

m12

Testing the Application:

Now we are ready to test the image we pulled in our container. As we already mentioned above, we have a sample Mule application that runs on HTTP port 9082 which we can test on our Kubernetes after deployment.

When we deploy our application through Dashboard,  services are automatically created and exposed. We can check using following kubectl describe service  test-mule-app :

m13

We can see all the details of the services exposed for our deployed application above. The service has exposed the external port 32285 which will be mapped to the internal port 9082 which is being used by sample Mule application deployed in the container.

To run the service following command we need minikube service test-mule-app :

m14

It will automatically open the browser and we can see our deployed Mule application responding:

m15

It confirms our application is running well!.

We only need to add the valid url that our sample application is using. Our sample application is using internally the following url http://localhost:9082/testApplication,  so, we just need to add /testApplication in the external url that our Kubernetes service has exposed.

So, the entire url will be: http://192.168.99.100:32285/testApplication as follows:

m16

Hope you like this article. In our future blogs, we will include some more details on Kubernetes and Mule applications.

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Anirban Sen Chowdhary

Anirban Sen Chowdhary is an information technology professional currently working on Java/J2ee, Esb and Integration platform. For more information, please visit http://anirbansenchowdhary.com and you can also follow https://twitter.com/Anir37

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>