Azure Kubernetes Service (AKS) simplifies running containerized applications by providing a fully managed Kubernetes environment with automated scaling, self-healing node health monitoring, and enterprise-grade cloud security. Whether you are migrating microservices to the cloud or learning cloud-native infrastructure, provisioning your first cluster is the foundation of modern DevOps workflows.
In this hands-on guide, you will learn how to provision an Azure AKS Cluster on the free pricing tier, configure Azure CLI and Kubectl on your local desktop, deploy a sample containerized application behind a public Load Balancer, and safely manage cloud resources to eliminate unexpected charges.
📦 GitHub Lab Repository & Manifests
All Kubernetes manifests and command templates used in this guide are available in our open-source repository:
👉 StackLayerOfficially/azure-aks-hands-on-labs (01-aks-cluster-deploy-app)
Understanding the Core Concepts
1. What is Azure Kubernetes Service (AKS)?
AKS is a managed container orchestration platform hosted on Microsoft Azure. In a self-hosted Kubernetes environment, you are responsible for maintaining the master control plane nodes, etcd database, and API servers. With AKS, Microsoft manages the control plane for free, leaving you with only the worker nodes to run your containerized apps.
2. What is the Azure CLI and Kubectl?
The Azure CLI (az) is the cross-platform command-line utility used to manage cloud infrastructure on Microsoft Azure (such as creating virtual networks, storage accounts, and AKS clusters). Kubectl is the official Kubernetes command-line tool used to deploy applications, inspect pod health, and manage workloads running inside the Kubernetes cluster.
Prerequisites
Before getting started, ensure you have:
- An active Azure Subscription (Free Trial, Student, or Pay-As-You-Go).
- Basic familiarity with terminal/command line interfaces.
- Administrator privileges on your local desktop to install CLI binaries.
⚠️ Disclaimer & Cloud Cost Notice
This tutorial is created strictly for educational and learning lab purposes. The configurations and manifests shown here are simplified demonstrations and should not be used directly in live production or enterprise environments without independent security reviews. Stack Layer and its technical team assume no responsibility or liability for any issues, outages, or data loss resulting from applying these commands. Always follow Step-05 to pause or delete your cluster when finished to protect your cloud balance.
Project Roadmap (To-Do List)
- Provision an Azure AKS Cluster via the Azure Management Portal.
- Install and authenticate Azure CLI and Kubectl on your local desktop.
- Explore AKS cluster resources using Kubectl and the Azure Portal.
- Deploy a sample containerized application and verify public internet access.
- Safely stop or delete Kubernetes resources to prevent unwanted cloud charges.
Step-01: Create AKS Cluster via Azure Portal
Sign in to the Azure Portal and search for Kubernetes services. Click Create > Kubernetes cluster and configure the following parameters:
1. Basics Tab
- Subscription: Select your active subscription
- Resource Group: Click Create new and enter
aks-rg - Cluster preset configuration: Dev/Test ($)
- Kubernetes Cluster Name:
aks-cluster - Region: Central US (or select your nearest preferred region)
- Fleet Manager: None (Leave to default)
- Availability zones: None (Leave to default for free/dev tier)
- AKS Pricing Tier: Free
- Kubernetes Version: Select the latest default stable version
- Automatic upgrade: Enabled with patch (recommended)
- Node security channel type: Node Image (Leave to default)
- Authentication and Authorization: Local accounts with Kubernetes RBAC
2. Node Pools Tab
Select your primary node pool (agentpool) and click Update to configure capacity:
- Node pool name:
agentpool - Mode: System
- OS SKU: Ubuntu Linux
- Availability zones: Zones 1, 2, 3
- Node size:
Standard_DS2_v2(2 vCPUs, 7 GiB memory) - Scale method: Autoscale
- Minimum node count: 2
- Maximum node count: 5
- Click Update to save node pool settings.
3. Networking Tab
- Private access: Unchecked (Public cluster)
- Public access: Unchecked (All authorized IP ranges allowed for lab testing)
- Network configuration: Azure CNI Overlay
- Bring your own Azure virtual network: Checked (Review the auto-populated virtual network and cluster subnet)
- Network Policy: None (Leave to default)
- Load balancer: Standard
4. Review + Create
- Leave Integrations, Monitoring, Security, and Tags at their default options.
- Click Review + Create. Once validation passes, click Create. Provisioning takes approximately 4–7 minutes.
Step-02: Explore the AKS Cluster on Azure Management Console
Once deployment is complete, navigate to your AKS cluster resource in the Azure Portal to explore the built-in management dashboards:
- Overview: Inspect cluster status, Kubernetes version, API server address, and node count.
- Kubernetes Resources: View live Pods, Deployments, Services, and Namespaces directly inside the Azure web console.
- Settings: Manage node pools, networking topology, and cluster upgrades.
- Monitoring: Review real-time CPU and memory telemetry.
Step-03: Install CLI Tools & Connect to AKS from Local Desktop
To manage your Kubernetes cluster programmatically, configure the Azure CLI and Kubectl on your local machine.
The easiest way to install the Azure CLI on Linux/Debian systems is through the official script maintained by the Azure CLI team:
[code] # Install Azure CLI (Ubuntu / Debian) curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Verify Azure CLI version az --version # Install Kubernetes CLI Tools (kubectl & kubelogin) via Azure CLI sudo az aks install-cli # Authenticate with Azure Cloud az login # Check kubectl version (Client & Server) kubectl version # Check kubectl client version offline kubectl version --client # Download cluster credentials into local kubeconfig az aks get-credentials --resource-group aks-rg --name aks-cluster # List cluster worker nodes kubectl get nodes kubectl get nodes -o wide # List Kubernetes namespaces kubectl get namespaces kubectl get ns # List all pods across all namespaces kubectl get pods --all-namespaces # List all Kubernetes objects across the entire cluster kubectl get all --all-namespaces [/code]Command Breakdown:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash: Downloads and executes Microsoft's official script to configure repository GPG keys and install the Azure CLI package automatically.az --version: Confirms that the Azure CLI core binary, Python environment, and plugins are properly installed.sudo az aks install-cli: Downloads and configures the latest stablekubectlandkubeloginbinaries into your system path (/usr/local/bin).az login: Launches an interactive authentication window in your default browser to connect your local terminal session with Microsoft Entra ID.kubectl version: Displays the local client binary version and connects to the AKS API server to report the cluster's control plane version.az aks get-credentials: Retrieves cluster access certificates and merges the API server endpoint into your local~/.kube/configfile.kubectl get nodes -o wide: Lists all cluster worker nodes with extended details, including internal IP, external IP, OS image, and container runtime engine.kubectl get namespaces (kubectl get ns): Lists all virtual workspace boundaries configured in the cluster.kubectl get pods --all-namespaces: Scans and reports running pods across all namespaces, including core system controllers inkube-system.kubectl get all --all-namespaces: Provides a high-level inventory of all Pods, Services, Deployments, and ReplicaSets active across your cluster.
Step-04: Review Manifests & Deploy Application Workload
To deploy our application declaratively, we organize our Kubernetes manifests inside a dedicated directory named kube-manifests/.
1. Review the Deployment Manifest (0A-Deployment.yml)
This manifest instructs Kubernetes to maintain 2 pod replicas running our containerized NGINX web application:
[code] apiVersion: apps/v1 kind: Deployment metadata: name: stacklayer-web-deployment spec: replicas: 2 selector: matchLabels: app: stacklayer-web template: metadata: name: stacklayer-web-pod labels: app: stacklayer-web spec: containers: - name: stacklayer-web-container image: stacklayer/kubernetes:nginx-v1 ports: - containerPort: 80 [/code]Manifest Breakdown:
replicas: 2: Ensures high availability by constantly maintaining two identical pods across your worker nodes.selector.matchLabels: Connects the deployment controller to pods tagged with the labelapp: stacklayer-web.image: stacklayer/kubernetes:nginx-v1: The container image pulled from Docker Hub to run inside each pod.containerPort: 80: Opens TCP port 80 inside the container for incoming web traffic.
2. Review the Service Manifest (0B-Service.yml)
To expose our private pods to the public internet, we declare a Kubernetes Service of type LoadBalancer. AKS automatically provisions an Azure Standard Load Balancer and assigns a dedicated public IP address:
Manifest Breakdown:
type: LoadBalancer: Signals to the Azure cloud-controller-manager to automatically create an Azure Public IP and Load Balancer rule.selector.app: stacklayer-web: Directs all incoming traffic from the load balancer to pods matching the labelapp: stacklayer-web.port: 80&targetPort: 80: Routes incoming public traffic on port 80 directly to container port 80 inside the pods.
3. Apply Manifests & Test Public Access
Apply both manifests to your AKS cluster with a single command:
[code] # Apply all manifests inside the kube-manifests directory kubectl apply -f kube-manifests/ # Verify that application pods are running kubectl get pods # Verify the Deployment controller status kubectl get deployment # Verify the Service and obtain the Public IP address kubectl get service -w [/code]Command Breakdown:
kubectl apply -f kube-manifests/: Scans the directory and declaratively creates both the Deployment and Service resources in a single batch.kubectl get pods: Verifies that your container replicas report aRunningstatus with1/1ready state.kubectl get deployment: Confirms that the desired replica count (2) matches currently available pods.kubectl get service -w: Streams real-time updates for the service. TheEXTERNAL-IPwill initially show<pending>while Azure provisions the Public IP and routes traffic, then displays the assigned IP address. PressCtrl + Conce the IP appears.
Copy the assigned EXTERNAL-IP and open it in your web browser: http://<External-IP>. You can also verify connectivity directly in your terminal:
Step-05: Clean Up Resources & Prevent Unwanted Cloud Charges
In cloud engineering, managing resource lifecycles is just as crucial as deploying them. Even on the AKS free tier, running worker node VMs (Standard_DS2_v2) and Azure Load Balancers consume cloud credits continuously. Depending on your workflow, choose one of the two cost-saving options below:
First: Delete the Application Workload
Before modifying cluster states, delete the demo deployment and public service:
[code] # Delete deployed application workloads kubectl delete -f kube-manifests/ [/code]Command Breakdown:
kubectl delete -f kube-manifests/: Gracefully terminates the running pods and de-provisions the Azure Load Balancer frontend IP address.
Option A: Stop the Cluster (Recommended If Practicing Later Labs)
If you plan to follow additional hands-on guides, you can stop the cluster to pause VM compute billing while keeping your configurations intact:
[code] # Stop the AKS cluster to pause compute billing az aks stop --resource-group aks-rg --name aks-cluster # When you are ready to resume, start it back up: az aks start --resource-group aks-rg --name aks-cluster [/code]Command Breakdown:
az aks stop: Powers down all virtual machine worker nodes and halts hourly compute billing immediately. All cluster settings, node pools, and network configs are preserved.az aks start: Resumes cluster operations and wakes up worker nodes in approximately 2–3 minutes.
Option B: Delete the Cluster Completely (Permanent Teardown)
If you are finished experimenting and want to ensure 100% zero future charges:
[code] # Permanently delete the resource group and all contained resources az group delete --name aks-rg --yes --no-wait [/code]Command Breakdown:
az group delete --name aks-rg: Permanently deletes the resource groupaks-rg, cluster, virtual networks, and managed disks.--yes: Bypasses interactive confirmation prompts.--no-wait: Executes asynchronously in the Azure background so you can close your terminal immediately.
Summary
In this guide, you built your foundational Kubernetes environment on Microsoft Azure:
- Provisioned an enterprise-ready Azure Kubernetes Service (AKS) cluster on the free pricing tier.
- Configured Azure CLI, Kubectl, and authentication credentials on your local machine.
- Explored live cluster topologies via both the terminal and the Azure Portal GUI.
- Deployed declarative manifests for a high-availability web app and exposed it publicly through an automated Azure Standard Load Balancer.
- Mastered resource lifecycle management with
az aks stopandaz group deleteto prevent unnecessary cloud costs.
“Did you successfully deploy your first app on your AKS cluster?”
If yes, leave a comment below! If you ran into any issues or have questions, feel free to drop them below as well.
Discussions