You will provision a managed AKS cluster, deploy a workload, and enable both cluster and horizontal pod autoscaling. By the end you will run Kubernetes in the cloud without operating the control plane yourself.

Learning Objectives

  • Create an AKS cluster with the az CLI.
  • Deploy a workload and expose it via a load balancer.
  • Enable cluster autoscaler and a Horizontal Pod Autoscaler.
  • Time: ~4 hours · Difficulty: Advanced · Prereqs: an Azure subscription and kubectl.

Architecture Overview

Environment Setup

You will need: the az CLI authenticated and kubectl.

Before you begin: AKS incurs cost; delete the resource group when finished.

Step-by-Step Execution

01
Create the cluster with autoscaling nodes
az aks create -g rg -n tyf-aks --node-count 2 --enable-cluster-autoscaler --min-count 2 --max-count 5 --generate-ssh-keys
Provisions a managed cluster with an autoscaling node pool.
02
Get credentials and deploy
az aks get-credentials -g rg -n tyf-aks && kubectl create deployment web --image=nginx:stable
03
Expose and add an HPA
$ kubectl expose deploy web --type=LoadBalancer --port=80 && kubectl autoscale deploy web --cpu-percent=60 --min=2 --max=10
service/web exposed horizontalpodautoscaler.autoscaling/web autoscaled

Progress So Far

Testing & Validation

kubectl get svc web -w && kubectl get hpa web

You should get an external IP and an HPA reporting current vs target CPU. If reachable and scaling, your AKS deployment works. Remember to az group delete -n rg to stop charges.

Troubleshooting
  • External IP pending: the Azure Load Balancer takes a minute to provision; keep watching.
  • HPA shows unknown: install the metrics-server (built in on AKS, may need a moment).
  • Quota errors: the region/subscription may cap node SKUs; pick a smaller VM size.

Extension Ideas

Key Results

  • Ran managed Kubernetes without operating the control plane.
  • Enabled cluster autoscaling from 2 to 5 nodes.
  • Added an HPA scaling pods from 2 to 10 on CPU.
  • Exposed the app via an Azure Load Balancer.