Quickstart: Create an Azure Kubernetes Service (AKS) Cluster

This guide will walk you through the process of creating a basic Azure Kubernetes Service (AKS) cluster using the Azure CLI. AKS simplifies deploying and managing containerized applications.

Prerequisites

Step 1: Log in to Azure

Open your terminal or command prompt and log in to your Azure account:

Bash
az login

This command will open a browser window for you to authenticate with your Azure credentials.

Step 2: Create a Resource Group

Azure resources are organized into logical containers called resource groups. Create a new resource group for your AKS cluster:

Bash
az group create --name myResourceGroup --location eastus

Replace myResourceGroup with a unique name for your resource group and eastus with your desired Azure region.

Step 3: Create an AKS Cluster

Now, create your AKS cluster. This command creates a cluster with a default configuration. You can customize many parameters for production environments.

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

This operation can take several minutes to complete.

Step 4: Connect to the Cluster

To connect to your Kubernetes cluster, you need to configure kubectl, the Kubernetes command-line client. Use Azure CLI to retrieve the cluster's credentials:

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

This command downloads credentials and configures the kubectl command to use them.

Step 5: Verify Cluster Access

Verify that the cluster is accessible by listing the nodes in your cluster:

Bash
kubectl get nodes

You should see output listing the single node that was created with your cluster.

Cluster created and accessible!

Next Steps

You have successfully created an AKS cluster. Here are some suggested next steps:

Important: Remember to clean up resources when you are finished to avoid incurring unnecessary Azure charges. You can delete the resource group, which will remove all associated resources, including the AKS cluster.