Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email

This article is the last in a 2 part series regarding Azure Kubernetes Service (AKS) clusters. Part 1 showed you how to create an AKS cluster and connect to it via the cloud shell. It also showed you how to connect to the Kubernetes dashboard.

Part 2  (this one) will show you how to deploy a simple application, test the application, monitor the health and logs, and delete the cluster.

So let’s get right too it.

Deploy an application

For this example, we are going to use a simple Kubernetes manifest file. This manifest file will define a desired state for the cluster we created in part 1. The below manifest file will create a Microsoft example application called Azure vote. The manifest file includes two Kubernetes deployments, one for the front end and the other for a Redis instance. It also includes two Kubernetes services, an internal service for the Redis instance and an external service so you can access the Azure Vote application.

Open cloud shell from within the Azure portal and make sure you’re in Bash and then type nano. You will now be in the nano text editor.

Copy the below yaml code to the nano window.

Now press Ctrl+O to save the file. Make sure you call it azure-vote.yaml. Once saved press Ctrl+X to exit nano.

To run the application you can use kubectl

Now for the Test

In a few moments, the application will start to spin up and become ready. You can check the progress by using the following command.

If it says pending then it is still deploying. Once you get an external IP address you know you are good to go.

Press Ctrl+C to drop back to the Bash prompt.

In a new tab enter the external IP address you got from the above command.

There you have it your app running in AKS.

What about Monitoring?

By default, when you create the cluster, container insights monitoring is enabled. This monitoring provides you access to health metrics for both the AKS cluster and all of your pods running on it.

Navigate to your Cluster resource in the Azure Portal and click on Insights on the left.

The first screen you see is related to the actual cluster. Above you can see that I increased the node count to 2. To view the pod’s health you need to click on Containers at the top.

To view the container logs you need to click on the container you want to see logs for. In the new blade that has popped up click on View Container Logs.

You will now be in the familiar Logs window. You can now use KQL to query the logs further.

Time to clean-up everything

Now that you have tested everything its a good idea to clean-up everything you have created to save you some money. To do this use the following command in Cloud Shell, but change the Resource Group and Cluster name to match yours.

After a while you cluster will be gone.

Unfortunately, the command above will not clean-up the Azure Active Directory service principal used by the AKS cluster. To delete the service principal you can use the following commands, just make sure you make them match your names.

There you have it, after following both parts you have created an AKS cluster, deployed an app, monitored it and then cleaned up everything. I hope you found this article helpful. If you have any questions please reach out in the usual methods.

Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

I agree