March 15, 2016 | Written by: Jason McGee
Categorized: Compute Services | Events
Share this post:
As of May 23rd IBM Bluemix Container Service now provides a native Kubernetes operations experience while removing the burden of maintaining master nodes. Kubernetes itself is based on the Docker engine for managing software images and instantiating containers. Get the details.
hack.summit was a virtual event spanning Feb. 22nd – 24th 2016 featuring programming language creators, open-source contributors and thought leaders. I had the opportunity to give a talk during hack.summit on Containers and Microservices (see the full talk hack.summit() 2016 by Pluralsight on YouTube).
As part of my talk, I built a demo to showcase the ideas I was discussing with Microservices. My hack.summit “mood ring” demo, built on IBM Bluemix, used Docker containers and services to display a real-time dashboard of the “tone” of the summit based on the Twitter hashtag #hacksummit. By tone, I mean being able to understand the natural language of each tweet and decide if the user was joyful or unhappy or neutral. It was a fun project that glued together some powerful technologies including Elastic Search, Kibana, Twitter, and Watson tone analytics while using IBM Bluemix and the IBM Container Service as a delivery platform.
Mood Ring design and implementation
Let’s take a look into how the demo was designed and built.
The basic flow of the demo is pretty straightforward. The demo reads all tweets from Twitter under the #hacksummit tag, passes them to Watson for tone analysis and then stores and indexes them in Elasticsearch. Kibana is then used to provide a simple dashboard on the results.
Where do I get the data?
Twitter is commonly used by participants to discuss virtual events, so I searched for tweets using #hacksummit. The Insights for Twitter service on Bluemix stores the last 2 years of data from the Twitter Decahose and provides basic APIs that allow us to search for tweets from a given hashtag. I decided to leverage the
v1/messages/search API to search a given keyword like “hacksummit” every 5 minutes and use the returned search results as the basis of my data. After searching, I sent the results into an analyzer API to analyze the data. I utilized a microservice architecture and chose containers as my delivery vehicle, packaging the code as the
twitter-data Docker image. This resulted in the
twitter-data container in the IBM Bluemix container service.
How did I analyze the data?
The Watson Tone Analyzer service leverages cognitive linguistic analysis to identify tones within the tweets containing #hacksummit. I developed a demo tone analyzer service that provides the analyzer API. The API takes raw JSON data from the
twitter-data container, sends it to the Watson Tone Analyzer service to analyze and then process the Watson analyzed result. There are official elasticsearch Docker images right off Docker Hub. IBM Containers in Bluemix allows me to not only run Docker images I built, but also the images from Docker Hub. I used the latest elastic search community image from Docker Hub to run my elastic search container to store and index the analyzed tone raw data.
How did I access the data?
Kibana is an open source data visualization plugin for Elasticsearch. It provides visualization capabilities on top of the content indexed on an Elasticsearch cluster. Similar to elastic search, there are official kibana Docker images from Docker Hub. By leveraging the latest official Kibana image, I ran the kibana container in IBM Bluemix with a publicly accessible endpoint so that everyone can easily view the visualized data using previously developed queries or their own queries. Below is the resulting dashboard:
In summary, to build this demo, I used two services from Bluemix: 1) Insights for Twitter and 2) Watson Tone Analyzer. I also ran four containers in Bluemix: 1) Twitter data 2) Tone analyzer and 3) ElasticSearch 4) Kibana. The first two containers required me to write a small amount of code (in Python in this example), along with customized Docker files. The 3rd and 4th containers required no coding. Of course, as is often the case, my code didn’t work when I first deployed….When I debugged the running containers in Bluemix, I leveraged the Logging and Monitoring service provided by IBM Containers to easily discover what was wrong. This was a big bonus as it required no changes to my containers to get that visibility.
The lifecycle doesn’t end with run!
After I got the 4 containers up running, I started to ask myself, what if there is a problem that requires a code fix? Do I want to go through the deployment process again and again with each problem that may arise? This is where IBM Delivery Pipeline for containers is useful. With very little scripting, I was able to build a multi-stage delivery pipeline with stages like Image Build, Image Vulnerability Check, Staging and Production. I configured the pipeline to run with every code commit to automatically run through the first 3 stages so I can have code deployed in the staging environment automatically. I have the production stage configured to run only after a manual trigger.
Build something cool!
I created this demo as a fun way to showcase IBM Bluemix & Watson for hack.summit. You can check out the code at IBMCloudPlatform/mood-ring on GitHub. I challenge you to build something cool at bluemix.net!