Azure Kubernetes Service (AKS)

Deploy and manage containerized applications with Azure Kubernetes Service.

Creating an Azure Kubernetes Service (AKS) Cluster

This guide walks you through the process of creating a new Azure Kubernetes Service (AKS) cluster using the Azure portal, Azure CLI, and Azure PowerShell.

Prerequisites

  • An Azure subscription. If you don't have one, you can create a free account.
  • Azure CLI installed and configured (for CLI method).
  • Azure PowerShell installed and configured (for PowerShell method).

Method 1: Using the Azure Portal

The Azure portal provides a user-friendly graphical interface for cluster creation.

  1. Sign in to the Azure portal.
  2. In the search bar, type "Kubernetes services" and select it from the services list.
  3. Click + Create then Create a Kubernetes cluster.
  4. Basics tab:
    • Select your Azure subscription and a resource group. Create a new one if needed.
    • Enter a name for your AKS cluster.
    • Choose a region for your cluster.
    • Select the Kubernetes version.
    • Specify the node count for your initial node pool.
    • Choose the VM size for your nodes.
  5. Node pools tab: Configure your system and user node pools, including VM sizes, auto-scaling, and availability zones.
  6. Networking tab: Configure networking settings like Kubernetes service address range and network policy.
  7. Integrations tab: Enable features like Azure Monitor, Container Registry, etc.
  8. Advanced tab: Configure advanced settings such as admission controllers, API server access, and pod security policy.
  9. Tags tab: Apply tags for organizing your Azure resources.
  10. Review your configuration and click Create.
💡 Note: It typically takes a few minutes for the AKS cluster to be deployed.

Method 2: Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for automating Azure resource management.

First, log in to your Azure account:

az login

Create a resource group (if you don't have one):

az group create --name MyResourceGroup --location eastus

Create the AKS cluster:

az aks create \
    --resource-group MyResourceGroup \
    --name myAKSCluster \
    --node-count 3 \
    --enable-addons monitoring \
    --generate-ssh-keys \
    --location eastus

This command creates a cluster named myAKSCluster with 3 nodes in the MyResourceGroup resource group in the East US region. The --enable-addons monitoring flag enables Azure Monitor for containers.

Method 3: Using Azure PowerShell

Azure PowerShell provides another way to manage your Azure resources programmatically.

First, connect to your Azure account:

Connect-AzAccount

Create a resource group (if you don't have one):

New-AzResourceGroup -Name "MyResourceGroup" -Location "East US"

Create the AKS cluster:

New-AzAksCluster -ResourceGroupName "MyResourceGroup" -Name "myAKSCluster" -Location "East US" -NodeCount 3 -EnableMonitoring

Connecting to your Cluster

Once your cluster is created, you need to configure kubectl to connect to it.

Get credentials for your cluster:

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

Verify the connection:

kubectl get nodes
Tip: For production environments, consider using node pools with different VM sizes and configuring auto-scaling to optimize costs and performance.

Next Steps