Wednesday, August 12, 2015

Google Compute Engine Load Balancer support for Apache Stratos - GSOC 2015 - Post 2

In previous post I described about the load balancers and Apache Stratos a little bit. So this post would help those who need to run Google compute engine load balancer in order to access their application.

In order to do this, you should deploy stratos in Google Compute Engine first. For that stratos wiki might help. After installing the stratos in Google Compute Engine you can deploy applications there. Then you need to configure a load balancer in order to access the application.


Google compute engine load balancer has been integrated to stratos as an extension. So it runs as a stand alone application. So we can run it in a seperate node or in the same node which the message broker runs.


In order to get the latest distribution zip file we need to download the stratos latest source and build it. For more details refer to stratos wiki. At the moment the extension code has not been merged to the master branch. So you can clone my fork of the Stratos git repository.


https://github.com/asankasanjaya/stratos


After building you can find the distribution zip file(org.apache.stratos.gce.extension-4.1.0.zip) in this directory.


/extensions/load-balancer/gce-extension/target/


Copy it and extract it to a proper directory. Now we have to do some configurations.


The extension should have the authority to access to Google compute engine behalf of you. For that we use OAuth 2.0 authentication method provided by GCE.


Login to your GCE account and do following.


a) Navigate to credentials section. Click on Create a new Client ID button if you don’t have a service account client ID yet.




b)  Select service account from pop up window and click on create Client ID. It will download a new json key to your computer. We don’t need that json key for this extension. Instead we need a P12 key.




c) Click on Generate new P12 key button. It will download a new P12 key to your computer. Store this key in a secure place. If you are using a node in GCE to run the extension, you need to upload this key to that node and store in a proper place.




d) Note the Email address provided for the client ID you created. You need to include this Email address later in gce-configuration.xml file.



e) Navigate to the extracted extension folder. Inside the conf folder open jndi.properties file using a text editor and update message broker IP and port information.

f) Configure google compute engine related properties. Specify the project name, project ID, region name(You should deploy your applications in this region), path to downloaded key file in step 3.4.c , gce account Id(This is the email address relevent to your client id.) and network name.


g) Update healthcheck related properties. Health checks are used to monitor the healthiness of nodes. if the health check fails to connect to the node at a given threshold we configure here, the node will be marked as unhealthy. You can keep these settings as defaults if you want. For more about health checks and related properties in google compute engine you can read here.
https://cloud.google.com/compute/docs/load-balancing/health-checks


h) Configure operation completion timeout. Each GCE API call which is done by extension, will be monitored until it get completes.  Within a defined time period, if the operation is not completed, further monitoring will be canceled and moved to the next API call.  We can configure that timeout in milliseconds.


i)  Configure the name prefix. Name prefix is used when new objects such as forwarding rules, target pools and health checks are being created in GCE. The prefix will be added before each object name. By using this prefix it will be easy to identify the objects created by stratos. First character must be a lowercase letter.




Now we can run the extension. Navigate to the bin folder and run gce-extension.sh script as root user.
sudo ./gce-extension.sh


After receiving the complete topology message to the extension it will create the relevant target pools, health checks and forwarding rules. So that you will be able to access the application as follows.

relevant-forwarding-rule-ip:port

This is the port you define at the application deployment stage. If you have defined several ports, you can use any port from them.

In next post I'm going to discuss about how I created this extension and the algorithm I used. That post may helpful for any one who is willing to create an extension for apache stratos load balancing. 

0 comments:

Post a Comment