How-tos

2.2 Deploy and scale a kubernetes chat app on IBM Bluemix

Share this post:

In the previous BlueChatter post, we looked at deploying and scaling a Node.js chat app using Cloud Foundry and Docker Container approach. In this post, we will look at how to deploy, scale and manage a Kubernetes application. We will reuse the same BlueChatter node.js application for this example.

A quick recap of the BlueChatter app, the BlueChatter app is a simple chat/IRC type application for the browser where it allows multiple users to chat when online at the same time. It uses Node.js for the runtime and Redis cloud service to store in memory the chat communication. Read on GitHub for more.

What it takes to deploy a Kubernetes app to Bluemix

Step 1) Get the required tools and plugins 

Step 2) Build the docker image

Step 3) Create a Cluster

Step 4) Deploy the cluster 

With these steps in place, you should have the BlueChatter app running within your Cluster on Bluemix.

The BlueChatter app should be running on: <Your-Cluster-Public-IP>:30089

In Step 4 we deployed the Cluster using this command:

kubectl create -f kubernetes.yml

The kubernetes.yml file contains all the configuration of the cluster that will be deployed to Bluemix. Looking at the kubernetes.yml file, we are creating a pod that contains the Redis cloud service and one pod for the application labeled as web. The nodePort is set to run on port: 30089, you can change that port to any port you wish. Now let’s look at the logs and a graphical view of the Cluster.

 

View Cluster pods Graphically

There are many ways in which we can view the cluster pods where been graphically or via the command line tool.

Here are two ways in which the Cluster pods can be viewed.

Option 1) Use Cloud Weave to view graphically the different pods and overall cluster setup.

Option 2)  To view logs locally we can use something l like kubetail to tail the logs of multiple pods https://github.com/johanhaleby/kubetail. Once installed you can do “kutetail fibo” to watch the logs.

Now that we can visualize the cluster pods, let’s look at scaling.

 

 

Scaling the BlueChatter Cluster

With Kubernetes we can very easily scale the number of replicas with very little work.

Step 1) Manual Scaling can be done using this command

kubectl scale --replicas=4 -f kubernetes.yml

 

Step 2) Auto Scaling can be done using this command

kubectl autoscale -f kubernetes.yml --cpu-percent=10 --min=1 --max=10

This tells Kubernetes to maintain an average of 10% CPU usage overall pods in our deployment and to create at most 10 pod replicas. When scaling the application, we can easily see the number of pods increasing and decreasing depending on the application load.

Useful Kubernetes commands

Find some useful Kubernetes commands here.

Also, check out the BlueChatter GitHub repo for step by step guide.

 

Additional Information

For more great samples like this check out the IBM-Bluemix GitHub.io page. The IBM-Bluemix GitHub.io site is a well-maintained, centralized, curated list of featured samples where you can find many samples in covering many Bluemix services.

IBM-Bluemix-GitHub.io page

 

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter: @twanawebtech

 

More Compute Services Stories

Report: Container Technology Global Perception Study

With the objective of bringing into focus a multi-national outlook on container technology, Cloud Foundry Foundation commissioned a study in the first quarter 2016.

Continue reading

Liberty and Eclipse: Enable a feature

WebSphere Liberty is the next generation application server, and Liberty and Eclipse make a great local development environment for developing Java EE applications. One task you’ll need to be able to perform is using Eclipse to enable a Liberty feature in the server configuration. This will enable applications running in the server to use that feature. In this excerpt from “Java EE, the next inception: Install a local Java EE development environment for WebSphere Liberty,” we’ll explore how enable additional features your local Liberty server using Eclipse.

Continue reading

Retirement of IBM Active Deploy Beta Service

We are excited that IBM Bluemix Container Service is going to be based on Kubernetes. With the move toward Kubernetes, the Active Deploy service (Beta) will be retired. We encourage you to use the rolling deployments feature native to Kubernetes, or use Cloud Foundry native capabilities or open source solutions for Cloud Foundry application deployments.

Continue reading