Skip to main content
In this guide, you’ll learn how to provision a Kubernetes cluster using Azure Kubernetes Service (AKS) on Microsoft Azure. This step-by-step tutorial is designed for beginners and includes detailed instructions to help you get started quickly.
Before you begin, ensure you have an active Azure account. If you’re new to Azure, take advantage of the 12-month free access and familiarize yourself with basic Azure configurations.
The image lists prerequisites for Azure, including an Azure account, active subscription, and Azure basics, with a link to Azure's free account FAQ.

Accessing the Azure Dashboard

Once logged into your Azure account, you will be greeted with a dashboard displaying various services. In this demonstration, we are using the free “KodeKloud free account.” To find the Azure Kubernetes Service (AKS), either search for “AKS” or select it directly from the available services list.
The image shows the Microsoft Azure portal homepage, displaying various services, recent resources, navigation options, tools, useful links, and mobile app download buttons.

Creating Your Kubernetes Cluster

Since no cluster exists yet, you’ll need to add a new cluster. This will take you to the “Create Kubernetes cluster” screen. Make sure that the appropriate subscription is selected, especially if you are using a free-tier subscription.
  1. Resource Group: Create a new resource group. For demonstration purposes, name it “voting app resource group”.
  2. Cluster Name: Choose an identifiable name such as “example voting app”.
  3. Kubernetes Version: Leave the default version (e.g., 1.16).
  4. Node Configuration: Considering this is a free-tier demonstration, select one node for the node size and leave the remaining options at their default values.
Under Authentication settings, select the option to create a new service principal. This service principal allows AKS to manage associated cloud resources seamlessly.
The image shows the "Create Kubernetes cluster" page on Microsoft Azure, focusing on authentication settings, including service principal, RBAC, and node pool OS disk encryption options.
After verifying your configuration, click on Review and create. Once the Create button becomes available, click it to initiate the deployment. The process starts with provisioning your resource groups, followed by the creation of your Kubernetes cluster. Please be patient, as the full deployment might take some time. Upon successful deployment, Azure will display a confirmation message.
The image shows a Microsoft Azure portal indicating a successful deployment completion for a resource group named "votingapp-resourcegroup."

Connecting to Your Cluster with Azure Cloud Shell

To locate your newly created resources, enter “voting app” in the Azure search bar. You should see both the Kubernetes service and your cluster. Next, access your cluster using the Azure Cloud Shell, which appears at the bottom portion of the screen. If prompted, follow the steps to create storage for Cloud Shell. While the Cloud Shell initializes, review these essential commands to connect to your AKS cluster:
Additionally, you might encounter a snippet in a Kubernetes configuration file like:
Scroll to the bottom of the documentation (if referenced) for further instructions on connecting to your cluster. The Azure Cloud Shell comes pre-installed with the kubectl client, so you can quickly grant access to your cluster.
The image shows a Microsoft Azure documentation page about connecting to a Kubernetes cluster using the Azure portal, featuring a screenshot of the Azure interface.

Configuring kubectl in Cloud Shell

In the Cloud Shell window, execute the following command to configure kubectl. Replace “myResourceGroup” and “myAKSCluster” with your actual resource group and cluster names:
After running the command, you will see messages similar to:
After configuring, verify connectivity by running:
For example, the output may appear as follows:

Deploying the Voting Application

With your single-node cluster up and running, it’s time to deploy the voting application. Follow these steps:
  1. Clone the Repository: Clone the GitHub repository containing the application’s YAML files.
  2. Deploy the Application Components: Execute the commands below in the order listed to deploy all necessary services and deployments:
  3. Verify Deployments: Check the status of your deployments and services using:
    A typical output might be:
In some cases, the result app service may initially show a pending state while the load balancer is being provisioned. Give it a few minutes to complete this process.

Testing Your Deployment

Once all deployments are confirmed (each showing one out of one pod ready) and the load balancers for both the voting and result services have been provisioned, you can test the applications:
  • Open your browser in a new tab to access the voting application using the external IP provided for the “voting-service”.
  • Similarly, open another tab to access the results application using the external IP of the “result-service”.
The image shows a split screen with equal blue and teal sections, labeled "CATS 50.0%" and "DOGS 50.0%".
Vote on the application and watch the result update in real time. This confirms that the applications are functioning correctly.

Clean Up

After finishing your demonstration and learning session, remember to delete the cluster and clean up your resources to prevent any unexpected charges. That concludes this Kubernetes on Azure AKS tutorial. Happy learning, and see you in the next guide!

Watch Video