Deploying WSO2 Micro Integrator 4.0.0 Project along with a connector through Jenkins pipeline to Kubernetes

This article is to explain how we can develop and deploy micro integrator project into kubernetes through Jenkins pipeline.

Prerequisite

  1. Setup NFS server to use as the persistence volume
  2. Setup MySQL database
  3. Setup Nexus Server
  4. Setup Jenkins Server

What we are going to setup

Once the pre-requisites are fine then we can start the development. First we will create a connector to start with that follow the below steps.

1. Connector Implementation

After a successful execution we can see a result like below:

Then load the project into one of your favourite IDE, here I’m using the Visual Studio code.

Under src/main/resources create a folder called fetchip_volume. Then create a file called fetchip.xml and add the below content

Then create a component.xml and add the below content in the same folder.

Then go to connector.xml and replace the below content.

Then make sure you are creating a folder called icon and adding both icon-small.gif and icon-large.gif otherwise there will be issue in importing the connector to the Integration Studio when attaching the connector to a project.

now our structure will be like below:

Also to add some logic to the Java code add the below.

Then execute the mvn clean install

When you build the connector sometimes can experience an error like the default mirror is blocked to overcome this go to the .m2 folder and create a file called settings.xml. and add the content as below.

If everything will be fine then you will see a log like below:

2. Adding the connector to a Project

Go to Integration Studio and create a project and add the connector or else if project creation also needs to be automated in future can use the below script to generate it. This was developed by Lakshani Gamage and I’m re-using that script here.

mkdir FetchIP and then get the location of the project then execute the project generator script.

Once this is executed properly the below structure will be created.

Now to start our implementation we can load the project to integration studio and then start to implement the logics.

Now we need to add our connector to the Integration studio to get it integrated.

Note: Specifically in MAC if you try to go to Add/Remove Connector functionality in the Integration studio you will get an error like below:

To fix this you need to add the below configuration to the file /Applications/IntegrationStudio.app/Contents/Info.plist

After adding restart the Integration Studio IDE. Then you will be able to continue without any issue.

Now Create a Sequence to use the Connector we have created into a project.

Then to invoke and test we need to create an API. Use the below synapse configuration to create the API.

Now we have successfully added the connector to the project.

3. Testing the API in the standalone Micro Integrator

and once all completed check the API using Postman client.

4. Preparation for kubernetes deployment

Then we need to update the wso2carbon.jks and the client-truststore.jks files , so for that under the Resources folder in the FetchIPDockerExporter, for now copy the files from a MI distribution and place it there.

Then go to Dockerfile and update with the below content.

Regarding the deployment.toml, based on our need we can add the database interactions and for this I’m using the default configuration and only want to parameterize the hostname and offset for testing purpose of the configuration.

This sample will be looks like below:

Then to do the deployments to kubernetes we need to prepare the deployment yaml file for the kubernetes.

To do that first create a folder inside the FetchIPDockerExporter as “kubernetesDeployment” and add the below content.

5. Preparing the Environment Variable Config Project

sample file contents:

dashboard-configmap.yaml

fetchip-configmap.yaml

mi-common-configmap.yaml

mi-common-secret.yaml

create the above secrets in the Jenkins as secret text.

Then do the deployment through pipeline. A sample pipeline script will be as below.

Sample Groovy file for deployment

K8sDeployerProd.groovy

6. Deploying the Dashboard

Then deploy the micro integrator dashboard to the kubernetes cluster.

sample deployment.yaml file

sample pipeline scripts

To release a build and push the image to nexus repository

to deploy the dashboard

sample K8sDeployer.groovy

7. Deploying the Micro Integrator Project

sample pipeline for build

sample pipeline for deploy

sample K8sDeployer.groovy

8. Deployment Order

  • then micro integrator dashboard
  • finally the micro integrator projects

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store