Build Micro Integrator CICD workflow for K8s deployment

Dushan Abeyruwan
4 min readAug 6, 2021

In this section, I’ll try to address one of the common requests we got recent past with regards to the container orchestration best practices we should follow in order to deploy integration-related use cases.

When you deploy your integrations as a developer, the main concern is to ensure the high availability and scalability of your system, this would become even more complicated when the business units have their own set of components. Therefore, you need to decide upon the number of worker nodes and the number of replicas that are required for the purposes of scaling the deployment and ensuring high availability.

K8s plays a special role when handling container orchestration, which avoids manual replication. Therefore, the concept of Continue Integration Continues Delivery embodies the best practices of automation with K8s deployment that would largely decouple decrease the complexities.

Micro Integrator CICD workflow

As depicted above, when an integration developer builds the specific integration needs with required unit tests using WSO2 integration Studio (IDE), once everything is finalized, the developer can commit the integration code piece to the source repository. Then, tools like Jenkins will act as coordinators for executing jobs such as pull from the git through git hooks, push images to the Docker hub. Then coordinate with K8s to set up and deploy the required image then validate the integration test cases.

Let's walk through how this can be done practically. For this, I’m planning to use already available resources from WSO2 documenation.

  • Setup the micro integration project, for that please do refer to here for more information. (refer Getting Started view, select the Hello Kubernetes template, you can create a template similar to below and then customize it per your integration needs)
  • For the demonstration purpose, I have created a mock API that generates a JSON response. That would be used as integration test evaluation
Helloworld API
Test case for Helloworld API
  • Commit the entire project to the source repository. Refer here.
  • Set up Jenkins for Jobs and coordination. You may follow here to for more information to understand how to configure Jenkins.
  • Build and run the integration within Jenkins local server before which ensures the basic validity.
  • Setup K8s deployment job

The Jenkins job defined at the above config would execute the following operations;

  1. Retrieve the committed code from the source repository.
  2. Assume the environment has Kubernties installed, It would install the Kubernetes API Operator. (The API operator for Kubernetes makes APIs a first-class citizen in the Kubernetes ecosystem. Similar to deploying microservices, you can use this operator to deploy APIs for individual microservices or compose several microservices into individual APIs).
  3. Installing nginx ingress controller for K8s (NGINX Ingress Controller is a best-in-class traffic management solution for cloud‑native apps in Kubernetes and containerized environments.).
  4. Navigating to the K8s exporter project, build the composite integration project.
  5. If all goes well, at the end of K8s deployment and setup, you should see a message similar to below.
  • The docker image should be committed to the docker registry.
  • You can check whether the K8s deployment is a success.
kubectl get pods  NAME                               READY   STATUS    RESTARTS   AGE hello-deployment-c68cbd55d-j4vcr   1/1     Running   0          3m k8s-api-operator-6698d8f69d-6rfb6   1/1     Running   0          2dcurl http://wso2ei.ingress.wso2.com/hello-world-service/HelloWorld -v
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to wso2ei.ingress.wso2.com (127.0.0.1) port 80 (#0)
> GET /hello-world-service/HelloWorld HTTP/1.1
> Host: wso2ei.ingress.wso2.com
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 06 Aug 2021 19:49:39 GMT
< Content-Type: application/json; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Accept: */*
< X-Request-ID: 6748dfd740c1178efda004b7e65a3a9e
< Access-Control-Allow-Methods: GET
< X-Forwarded-Host: wso2ei.ingress.wso2.com
< X-Forwarded-Proto: http
< Host: wso2ei.ingress.wso2.com
< X-Forwarded-Port: 80
< Access-Control-Allow-Headers:
< activityid: badef329-c53a-4197-b98f-9592cac98d98
< X-Forwarded-For: 192.168.65.6
< X-Real-IP: 192.168.65.6
< X-Scheme: http
<
* Connection #0 to host wso2ei.ingress.wso2.com left intact
{"Hello":"World Demo"}* Closing connection 0

Refer here to understand if you need to follow up on any troubleshooting steps.

--

--