Creating HA WSO2 Streaming Integrator Docker Images and Publishing to Amazon ECR

Ramindu De Silva
5 min readMar 20, 2020

--

In the modern days, everyone is dockerizing everything. In this article I’ll be briefly explain all the steps on how to build a WSO2 Streaming Integrator docker image configured for Minimum HA and how to push it to the Amazon Elastic Container Registry.

Creating the docker Images

Lets check out wso2 docker-ei Github repository and navigate to docker-ei/dockerfiles/alpine/streaming-integrator directory. The directory has a deployment.yaml file which is configured for minimum HA mode as per the Streaming Integrator minimum HA documentation.

Step 1: Changing the deployment.yaml

The minimum HA mode uses two datasources for clustering and persisting purposes. I have used MySQL databases to facilitate the requirement. Inorder to work with your database, the PERSISTENCE_DB and the WSO2_CLUSTER_DB datasource configurations should be changed. The changes has to be done in the following entries as shown below.

jdbcUrl: ‘jdbc:mysql://wso2.cqaut6indcir.us-east-2.rds.amazonaws.com:3306/persistencedb?useSSL=false’ username: root password: rootroot driverClassName: com.mysql.jdbc.Driver

Step 2: Enabling the docker container’s private IP to be replaced in HA configuration

In the HA mode, an event sync server will be started in Passive mode to which helps to keep the server states equal to the active node. The active node sends each and every event to the passive node via the event sync server. And also, when a persisting happens in the active node, a control message will be sent to the event sync server to trim the list of events persisted. So if the active node goes down, the passive node will get the persisted state from the database and use the remaining events in the event sync server to restore the state as if it was in the active node.

In order to do so, the two nodes should know the event sync server host. Since the hostname can be changed dynamically when a container starts, event sync server hosts (by default localhost)should be changed as well.

To cater this requirement I have added the following code segment in the docker-entrypoint.sh to get the private IP from the docker and to replace the entry in th deployment.yaml.

IP=$(ifconfig eth0 | grep “inet addr” | cut -d ‘:’ -f 2 | cut -d ‘ ‘ -f 1)DEPLOYMENT_YAML=${WSO2_SERVER_HOME}/conf/server/deployment.yamlecho “$IP”sed -i “s/localhost/$IP/” “$DEPLOYMENT_YAML”

Step 3: Building the docker images

Since we have to have 2 separate docker images for the two nodes for the ease of work. To build the 1st docker image, I will be hard coding the wso2.carbon.id to wso2-si-1 and use the following command to build the docker image.

docker build -t wso2si:1.0.0-alpine-ha1 .

To build the seconds image, I will be hard coding the wso2.carbon.id to wso2-si-2 and use the following command to build the docker image.

docker build -t wso2si:1.0.0-alpine-ha2 .

And we can see the docker images have created locally that is ready to be hosted in a docker environment.

Configuring AWS ECR and pushing the docker images

First of all we need to install AWS CLI. Use the link to install and it’s pretty straight forward.

Configuring the AWS CLI

Login to https://console.aws.amazon.com/iam/home and add a user.

In the add user form enter an username and click on next.

Add the user to a relevant group (In my case, I created a new group with Admin Privileges and added the user to the particular group)

Once the user is created you can get the Access Key ID and the Secret Access Key

Now, in your machine’s terminal after you execute aws configure four prompts will come up and you have to give the information as below.

  • Account Id (can be found in the MyAccount): 264342959920
  • Region (can be found in the url): us-east-2
  • Access Key (from what we generated): AKIAT3DARO4YI74ACFHZ
  • Secret Key (from what we generated): XXXXXXXX/HK4yFGu

Creating a repository in the ECR

In the amazon ECR, create a repository and name it as wso2.

Pushing the created docker images to the ECR

Then, Retrieve an authentication token and authenticate your Docker client to your registry using the following command. (The push commands are shown in the UI after the repository is been created)

aws ecr get-login-password — region us-east-2 | docker login — username AWS — password-stdin 469387825253.dkr.ecr.us-east-2.amazonaws.com/wso2

First tag the 2 docker images that we created

docker tag wso2si:1.0.0-alpine-ha2 469387825253.dkr.ecr.us-east-2.amazonaws.com/wso2:ha2docker tag wso2si:1.0.0-alpine-ha1 469387825253.dkr.ecr.us-east-2.amazonaws.com/wso2:ha1

Push the docker images to the ECR

docker push 469387825253.dkr.ecr.us-east-2.amazonaws.com/wso2:ha1docker push 469387825253.dkr.ecr.us-east-2.amazonaws.com/wso2:ha2

Now you can see the two Streaming Integrator docker images in the AWS ECR

Hope you have learnt a bit of Docker, AWS ECR and WSO2 Streaming Integrator.

--

--

No responses yet