Offering complete solutions in a short time to market is one of the biggest things DevOps organizations need to deal with these days. Regarding WSO2 products we have a range of various complexities regarding setting up WSO2 products. Now we can fulfill the short time to market task by applying Docker containers for all WSO2 products. In this blog I will give a short guideline to get a good kickstart.
First we need to apply for a WSO2 account. (If you haven’t done it yet) This can be done over here. We need this account later to login to the WSO2 Docker Hub, so that we are able to pull all the specific WSO2 Docker images we need for setting up an environment.
Further requirements: Install vagrant on your system, Virtualbox and git client.
Setting up a VM
Create directory with inside a normal file with Unix / UTF-8 format called “Vagrantfile” with the following content:
Also create a /share subdirectory.
Now we hit vagrant:
Vagrant will setup a Virtualbox with inside Ubuntu, Docker and Docker Compose. If all finished we can directly do an ssh and enter the Virtualbox environment:
Building Docker images and run
Next step is to git clone the WSO2 GitHub repo. For our example we will clone the repo for API Manager, but this can be done with other WSO2 products too. First cd to the /share sub directory and then do a :
Please take a look at the README to see all the commands needed for building and running the Docker images for WSO2 API Manager. This you will do in the Virtualbox we’ve just started up.
WSO2 offers 9 different deployment patterns for running on a Docker host. These patterns are the official WSO2 deployment architectures.
This pattern has one container running API Manager all in one, and a seperate container running a MySQL database. We use this pattern to easily run it on a local dev environment for implementation and local testing purposes.
This pattern deployes a distributed and clustered WSO2 API gateway, WSO2 API manager, API traffic manager, WSO2 API publisher / store, API key manager and WSO2 API analytics in seperate dedicated Docker containers, suitable for instance for setting up an active/passive situation on a VM or in the cloud. It also includes how to loadbalance directly to an NGINX loadbalancer. Loadbalancing WSO2 API manager with NGinx is a proven and very stable setup.
This pattern is an out of the box setup suitable for setting up a clustered API Manager solution inside a corporate infrastructure with a Demilitarized Zone (DMZ) and a local area network (LAN). All done with Docker Compose scripts.
A complete collection of pattern pictures can be found here: https://github.com/wso2/docker-apim/tree/master/docker-compose/patterns/design.
The simplest environment we will setup is Pattern1. Inside the virtual first go to /srv/share/docker-apim/tree/master/docker-compose/pattern-1/. Our VM has 4Gb RAM resources which is exactly what we need to run Pattern 1. For other patterns like Pattern 3 or 4 we need more resources. How to determine the exact number for resources is a seperate subject based on WSO2 product Capacity Management, which is out of scope for this blog.
But for now do a vagrant ssh and do the following:
In the background MySQL and the APIManager is started up in seperate Docker containers. Take note that the API Manager is available the moment that the start up is finished. Because over here it is a background process in detached mode, one of the ways to take notice about the progress is to check the APIM logs. This we can easily check with the following command:
We now see a trace of the full logs.
The final results
After the containers are all started up, we can open a browser and explore the various interfaces provided according to the README.md file for pattern-1. Take note we are running API Manager inside a virtual, so we need to use the VM IP address instead of the suggested “localhost”. The IP is “192.168.33.10” determined by the given Vagrant script. Login with username admin and password admin.
We have full posibilities regarding setting up WSO2 products in any desired pattern depending on the situation. Besides Docker Compose we also have full Docker Compose Swarm setup scripts to setup high available clusters. In combination with Amazon Web Services or any other common cloud provider, Docker Swarm is supported out of the box, and an environment is easily realised with short time to market. Another nice addition for supporting a DevOps organisation.
Thanks to Dominique Mulder for his feedback and contribution to this blog.
If you have any questions about this blogpost contact us via the comments section of this blog. View also our WSO2 Tutorials, webinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development Support, WSO2 Operational Support and WSO2 Training Programs.