DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • 3 Reasons for the Mounting Demand for Smart Cloud-Native Application Development
  • Manage Microservices With Docker Compose
  • Common Performance Management Mistakes
  • An Overview of Popular Open-Source Kubernetes Tools

Trending

  • Enforcing Architecture With ArchUnit in Java
  • MCP Servers: The Technical Debt That Is Coming
  • The End of “Good Enough Agile”
  • Event Driven Architecture (EDA) - Optimizer or Complicator
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Sample Microservices Application Running on Kubernetes

Sample Microservices Application Running on Kubernetes

This example application will help you learn how to deploy a microservice to a Kubernetes cluster and install the Instana agent for monitoring.

By 
Steve Waterworth user avatar
Steve Waterworth
·
Apr. 05, 18 · Tutorial
Likes (9)
Comment
Save
Tweet
Share
22.5K Views

Join the DZone community and get the full member experience.

Join For Free

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.

$ echo -n "your unique agent key" | base64

Save the changes to the deployment. Then deploy the agent.

$ kubectl create -f instana-agent.yaml
namespace "instana-agent" created
serviceaccount "instana-admin" created
secret "instana-agent-secret" created
daemonset "instana-agent" created

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.

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert -f ../docker-compose.yaml
    kompose.version: 1.8.0 (0c0c027)
  creationTimestamp: null
  labels:
    io.kompose.service: web
  name: web
spec:
  type: LoadBalancer
  ports:
    - name: "8080"
    port: 8080
    targetPort: 8080
    nodePort: 30080
  selector:
    io.kompose.service: web
status:
  loadBalancer: {}

Create a separate namespace to put the application in and deploy the application:

$ kubectl create namespace robot-shop
$ kubectl -n robot-shop create -f K8s

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 containerized 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 containerized 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.

About Instana:

As the leading provider of Application Performance Management solutions for containerized microservice applications, Instana applies automation and artificial intelligence to deliver the visibility needed to effectively manage the performance of today’s dynamic applications across the DevOps lifecycle. Founded by Application Monitoring veterans, Instana provides true AI-powered APM to help organizations deliver high-performance applications today and in the future. Visit us at https://instana.com to learn more.

Kubernetes application microservice

Published at DZone with permission of Steve Waterworth, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • 3 Reasons for the Mounting Demand for Smart Cloud-Native Application Development
  • Manage Microservices With Docker Compose
  • Common Performance Management Mistakes
  • An Overview of Popular Open-Source Kubernetes Tools

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!