2.2 Deploy and scale a kubernetes chat app on IBM Bluemix
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 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 http://bit.ly/2qzWkb8. Once installed you can do “kutetail fibo” to watch the Fibonacci service 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.
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.
If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter: @twanawebtech
Share this post:
via Bluemix Blog https://ibm.co/2pQcNaA
May 17, 2017 at 05:09AM