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 How-tos Stories

Home automation powered by Cloud Functions, Raspberry Pi, Twilio and Watson

Over the past few years, we’ve seen a significant rise in popularity for intelligent personal assistants, such as Apple’s Siri, Amazon Alexa, and Google Assistant. Though they initially appeared to be little more than a novelty, they’ve evolved to become rather useful as a convenient interface to interact with service APIs and IoT connected devices.

Continue reading

Interpreting Spring Social Twitter Data with Watson Tone Analyzer

In this post, I'll show you how to build a basic Spring app with Twitter login using Spring Social. Then we'll use Watson Tone Analyzer to determine the dominant emotion from each of the tweets on the time of the logged-in user. The project we will create will be similar to the Accessing Twitter Data Spring guide, but with a few modifications.

Continue reading

Arria brings Natural Language Generation to IBM Cloud

The Arria Natural Language Generation APIs service is an addition to the Finance category on the IBM Cloud platform. This blog post shows you how to get started with Arria’s Natural Language Generation APIs service on the IBM Cloud platform.

Continue reading