Get Started with Azure Kubernetes Service (AKS)

This guide will walk you through the essential steps to create and deploy your first application on Azure Kubernetes Service (AKS). AKS simplifies deploying, managing, and scaling containerized applications.

Prerequisites

Before you begin, ensure you have the following:

Step 1: Install Necessary Tools

You'll need the Azure CLI and kubectl, the Kubernetes command-line tool.

If you haven't already, install the Azure CLI: Azure CLI Installation.

Install kubectl using the Azure CLI:

az aks install-cli

Step 2: Create an AKS Cluster

Let's create a basic AKS cluster. This command creates a resource group named myResourceGroup and an AKS cluster named myAKSCluster within it. Replace your-unique-name with a globally unique name for your cluster.

az group create --name myResourceGroup --location eastus
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys

This command may take several minutes to complete.

Step 3: Connect kubectl to Your AKS Cluster

Once the cluster is created, configure kubectl to connect to your AKS cluster. Use the following command to download credentials and merge them into the kubectl configuration file:

az aks get-credentials --resource-group myResourceGroup --name myAKSCluster

To verify the connection, run a command to list the nodes in your cluster:

kubectl get nodes

You should see output listing the node(s) in your cluster.

Step 4: Deploy an Application to AKS

Now, let's deploy a simple application to your AKS cluster. We'll use the "Azure Samples" version of the "aks-voting-app" for this example.

kubectl create deployment azure-vote-front --image=mcr.microsoft.com/azuredocs/azure-vote-front:v1

This command creates a Kubernetes Deployment named azure-vote-front and deploys the specified container image.

Step 5: Expose Your Application to the Internet

To make the application accessible from the internet, create a Kubernetes Service of type LoadBalancer. This service provisions an external IP address from Azure infrastructure and assigns it to the Service to route external traffic.

kubectl create service loadbalancer azure-vote-front --port 80 --type LoadBalancer --selector app=azure-vote-front

It can take a few minutes for the LoadBalancer service to provision and be assigned an external IP address. You can monitor the status with the kubectl get service command:

kubectl get service azure-vote-front -w

When the EXTERNAL-IP field shows an IP address, use Ctrl+C to stop the watch process.

Tip: If you encounter issues with kubectl get service not showing an External IP, ensure your cluster has network connectivity and that your Azure subscription has IP address quotas available in the region.

Step 6: View the Application

Get the external IP address of the service:

kubectl get service azure-vote-front --output jsonpath='{.status.loadBalancer.ingress[0].ip}'

Copy the external IP address and paste it into your web browser. You should see the Azure Vote web application.

Deploy Your First App

Next Steps

Congratulations! You've successfully deployed a containerized application to AKS.