Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
AKS with Azure Load Balancer
📖 Scenario: You are setting up a simple Azure Kubernetes Service (AKS) cluster to run a web application. You want to expose the application to the internet using an Azure Load Balancer to distribute traffic evenly across your pods.
🎯 Goal: Build an AKS cluster configuration that deploys a basic web app and exposes it using an Azure Load Balancer service type.
📋 What You'll Learn
Create a Kubernetes deployment manifest with a single container running nginx
Add a service manifest of type LoadBalancer to expose the deployment
Configure the service to listen on port 80 and forward traffic to the pods
Ensure the service uses the Azure Load Balancer to distribute incoming traffic
💡 Why This Matters
🌍 Real World
This project simulates deploying a web application on AKS and exposing it to the internet using Azure Load Balancer, a common real-world cloud infrastructure task.
💼 Career
Understanding how to deploy applications on AKS and expose them with Azure Load Balancer is essential for cloud engineers and DevOps professionals working with Azure.
Progress0 / 4 steps
1
Create the Deployment Manifest
Create a Kubernetes deployment manifest named deployment.yaml with a deployment called nginx-deployment. It should run 3 replicas of the nginx container using the image nginx:latest. Use the container port 80.
Azure
Hint
Use kind: Deployment and specify replicas: 3. The container image should be nginx:latest and expose port 80.
2
Add the Service Manifest
Create a Kubernetes service manifest named service.yaml with a service called nginx-service. Set the service type to LoadBalancer and select pods with label app: nginx. The service should listen on port 80 and forward traffic to target port 80.
Azure
Hint
Use kind: Service with type: LoadBalancer. The selector must match app: nginx. Set port and targetPort to 80.
3
Apply the Manifests to AKS
Write the Azure CLI commands to apply both deployment.yaml and service.yaml manifests to your AKS cluster using kubectl. Use the exact commands kubectl apply -f deployment.yaml and kubectl apply -f service.yaml.
Azure
Hint
Use kubectl apply -f deployment.yaml and kubectl apply -f service.yaml to deploy your manifests.
4
Verify the Load Balancer External IP
Write the kubectl command to check the external IP address assigned by the Azure Load Balancer to the nginx-service. Use the exact command kubectl get service nginx-service.
Azure
Hint
Use kubectl get service nginx-service to see the external IP assigned by the Azure Load Balancer.
Practice
(1/5)
1. What is the primary purpose of using an Azure Load Balancer with AKS (Azure Kubernetes Service)?
easy
A. To store data persistently for containers
B. To distribute incoming network traffic evenly across multiple pods
C. To build container images automatically
D. To monitor container resource usage
Solution
Step 1: Understand AKS and Load Balancer roles
AKS runs containerized apps, and Azure Load Balancer distributes traffic to these apps.
Step 2: Identify the main function of Load Balancer
It balances incoming requests across pods to improve availability and scalability.
Final Answer:
To distribute incoming network traffic evenly across multiple pods -> Option B
A. An Azure Load Balancer is created and routes port 80 traffic to pods on port 8080
B. Pods are exposed only inside the cluster on port 8080
C. Traffic on port 8080 is blocked by default
D. A NodePort service is created exposing port 80 on all nodes
Solution
Step 1: Analyze service type and ports
Service type is LoadBalancer, so Azure LB is created. It listens on port 80 externally and forwards to targetPort 8080 on pods.
Step 2: Understand traffic flow
External traffic on port 80 hits Azure LB, which routes it to pods' port 8080 matching selector app: myapp.
Final Answer:
An Azure Load Balancer is created and routes port 80 traffic to pods on port 8080 -> Option A
Quick Check:
LoadBalancer + port mapping = external traffic routing [OK]
Hint: LoadBalancer routes external port to pod targetPort [OK]
Common Mistakes:
Thinking pods are exposed only internally
Confusing NodePort with LoadBalancer
Assuming traffic is blocked without explicit rules
4. You deployed an AKS service with type: LoadBalancer, but the external IP remains <pending> for a long time. What is the most likely cause?
medium
A. The service selector labels do not match any pods
B. The Kubernetes cluster is not running
C. The pods are not listening on the targetPort
D. The Azure Load Balancer quota is exceeded in the subscription
Solution
Step 1: Understand LoadBalancer IP allocation
Azure assigns an external IP when provisioning the Load Balancer. If quota is exceeded, IP remains pending.
Step 2: Differentiate causes
Selector mismatch or pod ports cause traffic issues but do not block IP assignment. Cluster down would prevent service creation.
Final Answer:
The Azure Load Balancer quota is exceeded in the subscription -> Option D
Quick Check:
Pending IP often means quota limit reached [OK]
Hint: Pending IP usually means Azure LB quota exceeded [OK]
Common Mistakes:
Blaming selector mismatch for IP assignment delay
Assuming pods not listening blocks IP allocation
Thinking cluster down still allows service creation
5. You want to design a highly available AKS application exposed via Azure Load Balancer that can handle sudden traffic spikes. Which combination of strategies is best?
hard
A. Use type: NodePort service and rely on Azure VM scale sets only
B. Use type: ClusterIP service with manual pod scaling and no health probes
C. Use type: LoadBalancer service, enable Horizontal Pod Autoscaler, and configure Azure Load Balancer health probes
D. Use type: ExternalName service pointing to an external DNS
Solution
Step 1: Choose correct service type for external exposure
type: LoadBalancer creates Azure LB to distribute traffic externally.
Step 2: Enable autoscaling and health checks
Horizontal Pod Autoscaler adjusts pod count for traffic spikes; health probes ensure LB routes only to healthy pods.
Step 3: Evaluate other options
ClusterIP is internal only; NodePort exposes ports but lacks automatic LB; ExternalName is DNS mapping, not load balancing.
Final Answer:
Use type: LoadBalancer service, enable Horizontal Pod Autoscaler, and configure Azure Load Balancer health probes -> Option C
Quick Check:
LoadBalancer + autoscale + health probes = high availability [OK]
Hint: Combine LoadBalancer, autoscaling, and health probes for HA [OK]
Common Mistakes:
Using ClusterIP or ExternalName for external traffic