Overview
Azure Kubernetes Service (AKS) provides a managed Kubernetes environment, reducing the complexity of container orchestration. This guide walks you through creating a cluster, deploying a sample application, and cleaning up resources.
Prerequisites
- Azure subscription (you can create a free account)
- Azure CLI 2.0+ installed (
az version) - kubectl installed (
az aks install-cli) - Git installed
1. Create an AKS Cluster
Run the following commands in a terminal. Adjust --resource-group and --name as needed.
az group create --name MyResourceGroup --location eastus
az aks create \
--resource-group MyResourceGroup \
--name MyAKSCluster \
--node-count 2 \
--enable-addons monitoring \
--generate-ssh-keys
az aks get-credentials --resource-group MyResourceGroup --name MyAKSCluster
2. Deploy a Sample Application
Clone the demo repository and apply the manifests.
git clone https://github.com/Azure-Samples/aks-helloworld.git
cd aks-helloworld
kubectl apply -f manifests/
Verify the deployment:
kubectl get pods -n hello-world
kubectl get svc -n hello-world
Expose the service externally (if not already):
kubectl expose deployment hello-world \
--type=LoadBalancer \
--name=hello-world-svc \
--port=80 \
--target-port=8080
After a few seconds, retrieve the public IP:
kubectl get svc hello-world-svc -n hello-world
3. Clean Up Resources
When you're done, delete the resource group to avoid charges:
az group delete --name MyResourceGroup --yes --no-wait