Reader small image

You're reading from  Hands-On Kubernetes on Azure

Product typeBook
Published inMar 2019
PublisherPackt
ISBN-139781789536102
Edition1st Edition
Right arrow
Authors (2):
Shivakumar Gopalakrishnan
Shivakumar Gopalakrishnan
author image
Shivakumar Gopalakrishnan

Shivakumar Gopalakrishnan is DevOps architect at Varian Medical Systems. He has introduced Docker, Kubernetes, and other cloud-native tools to Varian product development to enable "Everything as Code". He has years of software development experience in a wide variety of fields, including networking, storage, medical imaging, and currently, DevOps. He has worked to develop scalable storage appliances specifically tuned for medical imaging needs and has helped architect cloud-native solutions for delivering modular AngularJS applications backed by microservices. He has spoken at multiple events on incorporating AI and machine learning in DevOps to enable a culture of learning in large enterprises. He has helped teams in highly regulated large medical enterprises adopt modern agile/DevOps methodologies, including the "You build it, you run it" model. He has defined and leads the implementation of a DevOps roadmap that transforms traditional teams to teams that seamlessly adopt security- and quality-first approaches using CI/CD tools. He holds a bachelor of engineering degree from College of Engineering, Guindy, and a Master of Science degree from University of Maryland, College Park.
Read more about Shivakumar Gopalakrishnan

Gunther Lenz
Gunther Lenz
author image
Gunther Lenz

Gunther Lenz is senior director of the technology office at Varian. He is an innovative software R&D leader, architect, MBA, published author, public speaker, and strategic technology visionary with more than 20 years of experience. He has a proven track record of successfully leading large, innovative, and transformational software development and DevOps teams of more than 50 people, with a focus on continuous improvement. He has defined and lead distributed teams throughout the entire software product lifecycle by leveraging groundbreaking processes, tools, and technologies such as the cloud, DevOps, lean/agile, microservices architecture, digital transformation, software platforms, AI, and distributed machine learning. He was awarded Microsoft Most Valuable Professional for Software Architecture (2005-2008). Gunther has published two books, .NET – A Complete Development Cycle and Practical Software Factories in .NET.
Read more about Gunther Lenz

View More author details
Right arrow

Monitoring the AKS Cluster and the Application

In this chapter, you will learn how to monitor your cluster and the applications running on it. We will also show the use of the Microsoft Operations Management Suite (OMS) agent and the integration with Azure Portal, as well as set up alerts for critical events on the AKS cluster. You will be proactive in monitoring your cluster and the applications running on it, and you will be a hero for being able to proactively prevent errors from happening (launching more nodes when the cluster is CPU-constrained, for example) and for quickly resolving issues when they do happen.

In brief, the following topics will be covered in this chapter:

  • The kubectl commands for monitoring applications
  • Debugging applications
  • Review metrics reported by Kubernetes
  • Review metrics from OMS

Technical requirements

Commands for monitoring applications

Monitoring deployed applications on AKS along with monitoring Kubernetes health is essential to provide reliable service to your customers. There are two primary use cases for monitoring:

  • Debugging applications (used mostly when deploying/upgrading apps)
  • On-going monitoring to get alerts if something is not behaving as expected

We will handle the first use case of debugging when deploying/upgrading applications. The same methodology also applies for debugging running applications for which the commands are as follows:

kubectl get xxx
kubectl logs xxx

Before we start, we are going to have a clean start with our guestbook example.

If you have guestbook already running in your cluster, delete it by running the following command on the Azure Cloud Shell:

kubectl delete -f guestbook-all-in-one.yaml

Recreate the guestbook again using the following...

Debugging applications

Now that we have a basic understanding of how to monitor deployments, we can start seeing how we can debug issues with deployments.

In this section, we will introduce common errors and determine how to debug and fix them.

If not done already, run the following command:

kubectl create -f guestbook-all-in-one.yaml

After sometime, the services should be up and running.

Image Pull errors

In this section, we are going to introduce image pull errors by setting the image tag value to a non-existent one.

Run the following command on Azure Cloud Shell:

kubectl edit deployment/frontend

Next, change the image tag from v3 to v_non_existent by running the following commands:

image: gcr.io/google-samples/gb-frontend...

Metrics reported by Kubernetes

Kubernetes has a dashboard add-on, which is really cool and shows many metrics in a consumable form. However, it is a serious security risk and requires complicated configuration to set up securely.

We won't be installing it, as you get the same benefit, without the hassle from Azure Kubernetes Monitoring itself. If you still want to do it, please see https://blog.heptio.com/on-securing-the-kubernetes-dashboard-16b09b1b7aca.

We are going to list the metrics available by kubectl.

Node status and consumption

Run the following command to get information about the nodes on the cluster:

kubectl get nodes

The following lists their name, status, and age:

NAME                       STATUS    ROLES...

Metrics reported from OMS

Azure Portal shows many of the metrics that you would like to see combined with authorization as only personnel with access to the portal can see these metrics.

AKS Insights

The Insights section of the AKS tab provides most of the metrics you need to know about your cluster. It also has the ability to drill down to the container level. You can also see the logs of the container.

Logs of a container could contain sensitive information. So the rights to review logs should be controlled and audited.

Cluster metrics

Insights show the cluster metrics...

Summary

We started the chapter by showing how to use the kubectl events to monitor the application. Then we showed how powerful the created logs are to debug the application. The logs contain all the information that is written to stdout and stderr. We also touched on the Kuberenetes dashboards and showed you how to use the Kubernetes metrics for the operational monitoring of your deployments. Lastly, we explained the use of OMS to show the AKS metrics and environment variables, as well as logs with log filtering. You now have the skills to set alerts on any metric that you would like to be notified of by leveraging Azure Insights. You also learned how to debug application and cluster issues through the use of kubectl and OMS monitoring.

In the next chapter, we will learn how to secure an AKS cluster with role-based security, leveraging Azure Active Directory as an authentication...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Kubernetes on Azure
Published in: Mar 2019Publisher: PacktISBN-13: 9781789536102
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Shivakumar Gopalakrishnan

Shivakumar Gopalakrishnan is DevOps architect at Varian Medical Systems. He has introduced Docker, Kubernetes, and other cloud-native tools to Varian product development to enable "Everything as Code". He has years of software development experience in a wide variety of fields, including networking, storage, medical imaging, and currently, DevOps. He has worked to develop scalable storage appliances specifically tuned for medical imaging needs and has helped architect cloud-native solutions for delivering modular AngularJS applications backed by microservices. He has spoken at multiple events on incorporating AI and machine learning in DevOps to enable a culture of learning in large enterprises. He has helped teams in highly regulated large medical enterprises adopt modern agile/DevOps methodologies, including the "You build it, you run it" model. He has defined and leads the implementation of a DevOps roadmap that transforms traditional teams to teams that seamlessly adopt security- and quality-first approaches using CI/CD tools. He holds a bachelor of engineering degree from College of Engineering, Guindy, and a Master of Science degree from University of Maryland, College Park.
Read more about Shivakumar Gopalakrishnan

author image
Gunther Lenz

Gunther Lenz is senior director of the technology office at Varian. He is an innovative software R&D leader, architect, MBA, published author, public speaker, and strategic technology visionary with more than 20 years of experience. He has a proven track record of successfully leading large, innovative, and transformational software development and DevOps teams of more than 50 people, with a focus on continuous improvement. He has defined and lead distributed teams throughout the entire software product lifecycle by leveraging groundbreaking processes, tools, and technologies such as the cloud, DevOps, lean/agile, microservices architecture, digital transformation, software platforms, AI, and distributed machine learning. He was awarded Microsoft Most Valuable Professional for Software Architecture (2005-2008). Gunther has published two books, .NET – A Complete Development Cycle and Practical Software Factories in .NET.
Read more about Gunther Lenz