Sample Microservices Application Running on Kubernetes

February 27, 2018 by Steve Waterworth

Share this blog post on:

Stan’s Robot Shop – Sample Microservices Application

We introduced the sample microservice application called Stan’s Robot Shop in a previous post. In this article, we’ll take you through deploying that microservice application to a Kubernetes cluster and installing the Instana agent. The Robot Shop code already includes any extra set up, so all infrastructure technology will be automatically discovered; and every request will be traced end to end.

Install

First choose your environment. I will be using Google Cloud Platform Kubernetes Engine, you may also use minikube to run everything locally on your laptop. Once you have your Kubernetes cluster running, you’re going to install the Instana agent; then deploy the Robot Shop application.

Installing and Configuring Kubernetes

To work with Kubernetes, install a copy of kubectl locally on your machine. If you are using Google Kubernetes Engine, you will also need a copy of gcloud installed locally.

From the Google Kubernetes Engine dashboard, create a basic cluster of 3 nodes. Click on the connect button, then copy and paste the command to a shell prompt. This will configure the kubectl command to work against your newly created cluster. Test that everything is working so far:

$ kubectl cluster-info

Great, you have a running Kubernetes cluster and you can talk to it via kubectl.

Instana Agent

A deployment descriptor file is included with Stan’s Robot Shop code. You can download this via git:

$ git clone https://github.com/instana/robot-shop

If you do not have git installed, go to the Github page and click on the download link on the top right. This will download a Zip file, expand this into a directory.

Under the Robot Shop project directory, there is a sub-directory named instana. This is where you will find the YAML file that describes the agent deployment. You will need to edit this to configure your unique agent key, which must be base64 encoded. Get your unique agent key from the Instana dashboard under Management Portal.

The agent is deployed as a daemonset in its own namespace and is configured to only run on nodes with the label agent=instana. There is helper script label.sh which will label all nodes.

$ ./label.sh

The agent will take a moment or two to start and then report into the Instana backend, after which it will appear in the Instana dashboard.

Excellent work, the Instana dashboard is showing the empty Kubernetes cluster. Although we have not yet deployed the Robot Shop application, you can see that the Instana agent has already discovered a number of running containers (these are system containers like system processes of an operating system). You can learn more about what goes on under the covers of Kubernetes in a previous post.

Robot Shop Application

All the deployment and service definition files for deploying the Robot Shop to Kubernetes are included in the source under the K8s directory.

If you are using Google Kubernetes Engine, edit the deployment file for the web service: K8s/web-service.yaml Change the type from NodePort to LoadBalancer. No changes are required if you are using minikube.

It will take a few minutes for Kubernetes to download all the images and create the Pods to start running the application. As the Pods are created and the images start running, the Instana agent will automatically discover them and dynamically load the matching sensor to start monitoring the technology. You can watch this happen in real time on the Instana infrastructure dashboard.

If you are running via minikube, Stan’s Robot Shop will be available via the IP address of your minikube instance.

$ minikube ip

The above command will print out the IP address of your minikube instance, open your browser http://<minikube ip>:30080/

If you are using Google Kubernetes Engine, select Discovery & load balancing from the left menu, and then click on the web service. This will bring up the service details.

Click on the External endpoint link to open the shop in your browser. You’re an APM Rock Star now! You have just deployed a modern containerised microservices application with Kubernetes – with full monitoring. Don’t tell your boss how easy it really is with Instana; you will shatter the illusion.

Load Generation

You can click around the application to generate some traffic through the application (don’t worry you will not actually purchase anything). There is also a separate load generation utility under the load-gen directory. It runs locally via a Docker image: edit load-gen.sh and set the environment variable HOST to the URL of your deployed shop, save and run the script.

As some load is put through the application, Instana will automatically trace every request end-to-end and build the service map.

Conclusion

Monitoring a modern containerised orchestrated microservices application is not that difficult when you have Stan helping you. Watch for future posts when we cover topics such as End User Monitoring (EUM) and integrating OpenTracing spans.

Start your FREE TRIAL today!

Full Stack Visibility in 5 minutes! Instana makes it easy to manage the performance of your applications.

About Instana: As the leading provider of Automatic Application Performance Monitoring (APM) solutions for microservices, Instana has developed the automatic monitoring and AI-based analysis DevOps needs to manage the performance of modern applications. Instana is the only APM solution that automatically discovers, maps and visualizes microservice applications without continuous additional engineering. Customers using Instana achieve operational excellence and deliver better software faster. Visit https://instana.com to learn more.