Sailing Micro Integrator In Kubernetes

Arunan Sugunakumar
4 min readJan 31, 2022

WSO2 Micro Integrator (MI) was introduced with the intention of running a lightweight ESB inside containers, so that the ESB concept can be used with the Microservice architecture. The lower startup time, the reduced product size and single configuration file helps the product to be run on the container based environments. Services now can be decoupled, and they can be run on independent Micro Integrator instances. Starting and stopping of instance happens instantaneously which helps administrators to swap newer versions of the services with a smaller downtime.

Since Micro Integrator is container native, you can easily deploy it in a Kubernetes environment. To create the artifacts you can use the Integration Studio. For demonstration purposes, I am going to use one of the sample scenario that I used in one of my previous blogs. I’ll be using Micro Integrator 4.0.0 which comes under WSO2 API Manager 4.0.0 umbrella. You can use my previous blog as a guide to create the Integration project in WSO2 Integration Studio.

  1. First you need to create a Kubernetes Exporter project in Integration Studio. You can right click on an existing weather integration project and select New -> Kubernetes Exporter.
  2. In the New Kubernetes Exporter dialog box that opens, enter a name for the Kubernetes exporter and other parameters as shown below.

Here you need to note a couple of things.

  • Select Generate K8s Artifacts for as Pure K8s Artifacts.
  • Give a suitable Integration name.
  • I am selecting the base image as WSO2 MI 4.0.0. You can choose whatever you want.
  • Target Image repository is where you want to push your image to. When you build and push the image it will use the docker daemon settings on your environments to push the image.
  • By default http, https ports are exposed in the Service file. If you want to export any additional ports, you can mention it under Expose port(s) section.
  • In our initial API, the API key was included in our mediation itself. It is not a good practice to include secret keys inside the container images. Hence I am going to read it as an Environment variable. You can define Environment variables under Environment variables section.

After you have filled everything, click on Finish.

3. Once you click on Finish, you can see that the Studio has generated the necessary artifacts we need to create a Kubernetes deployment.

4. Since we are going to read the API_KEY from environment variable, we need to change the property mediator inside the API as below. (Reminder: This API was created in a previous blog.). Remember to check the Expression icon, since this is an Expression.

get-property(‘env’,’API_KEY’)

5. Now we need to build and push the image to the Docker repository. Go back to the Kubernetes export project pom file, and check the box of the OpenWeatherIntegrationCompositeExporter to include it inside the Micro Integrator image. After that, click on the Build & Push button on the top right side corner of the Exporter page.

6. Once you have pushed the image to your Docker repository, you can go and deploy Kubernetes artifacts in your Kubernetes cluster. (I am running a minikube cluster in my local environment.)

  • Copy the integration_k8s.yaml and integration_data.yaml into a separate folder.
  • Run the following command to create the configMap which contains the Environment variables (Your API_KEY).
kubectl apply -f integration_data.yaml
  • Once it is successfully applied, you can go ahead and deploy the integration_k8s.yaml which contains the Deployment and the Service.
kubectl apply -f integration_k8s.yaml
  • Now if you run the following command, you can see that the deployment is up and running.
kubectl get deploy

That’s it. You have successfully deployed, Micro Integrator in a Kubernetes cluster in just a few minutes. You can continue to play with the deployment by changing the replica values and all.

--

--

Arunan Sugunakumar

Software Engineer (Integration) @wso2, Graduated from University of Moratuwa (Computer Science & Eng) and GSOCer @intermineorg