Deploying and Accessing an Application to an AKS Cluster

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this lab, we will work with the Azure Command Line Interface (CLI) to create an AKS cluster. We will then use the kubectl command line utility to deploy an application to that cluster, and then add a kubernetes service, so that the application is accessible over the internet.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create AKS Cluster
  1. Create just the cluster, without any integrations with Azure Monitor, or Azure Policy.
  2. You can use either the provided Service principal or a System-assigned managed identity.
  3. The cluster can be created with the Azure Portal, CLI, PowerShell, or ARM template.
Deploy the Application
  1. Create a deployment to include two replicas of the application. The deployment can be applied in the Azure Portal or with the Azure Cloud Shell.
  2. The application should use the NGINX public Docker Hub image.
  3. Include resource minimum and maximum limits.
Access the Application Externally
  1. Add a LoadBalancer service to generate an external IP. The service can be added in the Azure Portal, or with the Azure Cloud Shell using the kubectl command line tool.
  2. Confirm access to the application using the external IP.

Additional Resources

You should be familiar with the following to use this hands on lab:

  • Docker and Containers
  • Kubernetes Deployments, Pods and Services
  • YAML
  • Azure Kubernetes Service
  • Azure Cloud Shell
  • Azure Command Line Interface

To complete this lab you will need to use manifest files when creating the deployment and the service. Once you have accessed the lab environment add the deployment.yaml and service.yaml to your Azure Cloud Shell environment.

The files can found in the following location:

https://github.com/linuxacademy/content-aks-basics/tree/master/Lab-Deploying-and-accessing-an-application-to-an-AKS-cluster

If you will be using the Azure Cloud Shell you will need to configure the storage.

  1. Open up the Azure Cloud Shell.
  2. In the welcome screen, select either Bash or PowerShell.
  3. Select "Show advanced settings".
  4. Set the Cloud Shell region to the same location as the existing resource group
  5. Under "Storage account" make sure "Create new" is selected.
  6. Manually provide a unique name for the Storage account.
  7. Under "File share" make sure "Create new" is selected.
  8. Manually provide a unique name for the File share.
  9. Select "Create storage".

Note about environment limitations:

Due to some limitations for the Cloud Playground/Hands On Lab environments there are some actions that are not permitted. One of them is that the user account does not have permission to create a new resource group. When creating an AKS cluster, Azure will create the AKS service in your existing resource group and then create another resource group to host all the other infrastructure needed for the cluster such as networking, storage and any log analytics workspaces.

How does this apply to our scenario?

  • Deploying in the Azure Portal

    • An error will occur when trying to deploy an AKS resource in the Azure Portal and in the “Integrations” tab the “Container Monitoring” is set to enabled. If you disable that it should work.
  • Deploying from Azure CLI

    • An error will occur when trying to deploy an AKS resource using the Azure CLI if you include the --enable-addons monitoring parameter. If you deploy the resource without that parameter (see guide for full command), it should work.

I understand that this is a bit confusing due to the unique limitations of the ACG environments so please feel free to reach out if you are experiencing problems or if you have any other questions.

Here is some more information about the environment limitations:

  • Linux Academy
    • https://pinehead.zendesk.com/hc/en-us/articles/360004687055-What-can-I-do-with-the-Azure-Sandbox-
  • A Cloud Guru
    • https://help.acloud.guru/hc/en-us/articles/360001389296-Azure-Cloud-Sandbox

Additionally, here is some more information regarding the additional AKS resource group creation from the Microsoft documentation if you are interested:

https://docs.microsoft.com/en-us/azure/aks/faq#why-are-two-resource-groups-created-with-aks

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?