Azure Kubernetes Service (AKS) — Complete Guide for .NET Lead
Azure Kubernetes Service (AKS) is Microsoft's managed Kubernetes platform for deploying, scaling, and managing containerized applications. It is one of the most important Azure services for .NET Leads, Solution Architects, and Cloud Engineers.
Official Documentation
Azure Kubernetes Service (AKS) Documentation
Table of Contents
What is AKS?
Why Kubernetes?
AKS Architecture
Real-Time Enterprise Example
Kubernetes Core Components
AKS Cluster Architecture
Deploying .NET Applications
Scaling
Networking
Storage
Security
Monitoring
CI/CD with Azure DevOps
Best Practices
Lead-Level Interview Questions
1. What is Azure Kubernetes Service (AKS)?
AKS is a fully managed Kubernetes service that allows you to deploy and orchestrate Docker containers without managing the Kubernetes control plane.
Azure manages:
Kubernetes Control Plane
API Server
etcd
Scheduler
Controller Manager
Upgrades (optional managed upgrades)
High Availability for the control plane
You manage:
Applications
Containers
Deployments
Services
Networking configuration
Security policies
2. Why Kubernetes?
Imagine an enterprise with 50 microservices.
Without Kubernetes:
Manual deployment
Manual scaling
Difficult upgrades
Downtime
Resource wastage
With Kubernetes:
Automatic deployment
Self-healing
Auto Scaling
Rolling Updates
Load Balancing
Service Discovery
3. Real-Time Architecture
Users
|
Azure Front Door
|
Azure API Management
|
Azure Kubernetes Service (AKS)
|
+-----------------------------------+
| Order API |
| Payment API |
| Inventory API |
| Notification API |
+-----------------------------------+
|
Azure SQL | Azure Service Bus | Redis
4. Kubernetes Components
Cluster
Collection of worker machines (nodes).
Node
Virtual machine running containers.
Pod
Smallest deployable unit.
Usually one application container.
Deployment
Maintains desired number of Pods.
ReplicaSet
Keeps required Pods running.
Service
Provides stable networking for Pods.
Ingress
Routes external traffic into the cluster.
5. AKS Architecture
Azure Kubernetes Cluster
|
+------------------------+
| Control Plane (Azure) |
+------------------------+
|
Worker Nodes
| | |
Pod Pod Pod
6. Real-Time Banking Example
Mobile App
|
API Management
|
AKS Cluster
|
-------------------------
Order Service
Payment Service
Account Service
Notification Service
-------------------------
|
Azure SQL Database
Azure Service Bus
Each microservice runs independently.
7. Deploying a .NET API
Create API:
dotnet new webapi
Build Docker image:
docker build -t order-api:v1 .
Push to Azure Container Registry:
docker push myregistry.azurecr.io/order-api:v1
Deploy to AKS.
8. Kubernetes Deployment YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 3
selector:
matchLabels:
app: order-api
template:
metadata:
labels:
app: order-api
spec:
containers:
- name: order-api
image: myregistry.azurecr.io/order-api:v1
ports:
- containerPort: 80
9. Service YAML
apiVersion: v1
kind: Service
metadata:
name: order-service
spec:
selector:
app: order-api
ports:
- port: 80
targetPort: 80
type: LoadBalancer
10. Scaling
Manual:
kubectl scale deployment order-api --replicas=5
Automatic:
CPU Usage
Memory Usage
Custom Metrics
using the Horizontal Pod Autoscaler (HPA).
11. Rolling Updates
Instead of stopping all Pods:
Version 1
↓↓↓↓
Replace one Pod at a time
↓↓↓↓
Version 2
Users experience little or no downtime.
12. Self-Healing
If one Pod crashes:
Pod 1 ✔
Pod 2 ❌
↓
Kubernetes creates new Pod
↓
Pod 2 ✔
13. Networking
AKS supports:
ClusterIP
NodePort
LoadBalancer
Ingress Controller
For internet-facing applications, Ingress is commonly used.
14. Storage
Persistent storage through:
Azure Managed Disks
Azure Files
Azure Blob Storage (application integration)
Persistent Volumes ensure data survives Pod restarts.
15. Security
Best practices:
Microsoft Entra ID integration
Azure RBAC
Managed Identity
Azure Key Vault
Network Policies
Private Cluster
Secrets management
Image scanning
16. Monitoring
Use:
Azure Monitor
Application Insights
Container Insights
Log Analytics Workspace
Monitor:
CPU
Memory
Pod Health
Node Health
Restart Count
Response Time
Logs
17. Azure DevOps Pipeline
Developer
|
Git Push
|
Azure DevOps
|
Build
|
Unit Tests
|
Docker Build
|
Push to ACR
|
Deploy to AKS
18. Real-Time Insurance Example
Claim submitted:
Web Portal
|
AKS
|
Claim Service
|
Service Bus
|
Notification Service
|
Email Sent
Each service scales independently.
19. Best Practices
Use Azure Container Registry.
Use Managed Identity.
Enable Horizontal Pod Autoscaler.
Configure resource requests and limits.
Use readiness and liveness probes.
Store secrets in Azure Key Vault.
Monitor with Azure Monitor and Container Insights.
Keep Kubernetes versions updated.
Use rolling deployments or blue/green strategies.
20. Lead-Level Interview Questions
Basic
What is Kubernetes?
What is AKS?
What is a Pod?
What is a Deployment?
What is a Service?
Intermediate
Difference between Pod and Container?
What is ReplicaSet?
What is Ingress?
What is Horizontal Pod Autoscaler?
How does AKS integrate with Azure Container Registry?
How do rolling updates work?
What are liveness and readiness probes?
Lead-Level
When would you choose AKS over Azure App Service?
How would you secure an AKS cluster?
How would you deploy 100 microservices?
How would you design multi-region AKS?
How would you implement zero-downtime deployments?
How would you troubleshoot failing Pods?
How would you optimize AKS costs?
How would you monitor a production AKS environment?
21. Lead-Level Interview Answer
"In our enterprise microservices platform, we deployed ASP.NET Core services to Azure Kubernetes Service. Docker images were built through Azure DevOps pipelines and stored in Azure Container Registry. AKS automatically orchestrated Pods, handled rolling updates, and used Horizontal Pod Autoscaler to scale services based on CPU utilization. Secrets were stored in Azure Key Vault and accessed using Managed Identity. Azure Monitor, Container Insights, and Application Insights were used for end-to-end observability. This architecture enabled high availability, zero-downtime deployments, and independent scaling of each microservice, making it suitable for large-scale production workloads."

No comments:
Post a Comment