Why Kubernetes?
Kubernetes handles container orchestration — auto-scaling, self-healing, rolling deployments, and service discovery. It's the standard for production microservices.
Deployment YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: blog-api
spec:
replicas: 3
selector:
matchLabels:
app: blog-api
template:
metadata:
labels:
app: blog-api
spec:
containers:
- name: blog-api
image: myregistry.azurecr.io/blog-api:latest
ports:
- containerPort: 8080
env:
- name: ConnectionStrings__Default
valueFrom:
secretKeyRef:
name: blog-secrets
key: db-connection
Service & Ingress
apiVersion: v1
kind: Service
metadata:
name: blog-api-svc
spec:
selector:
app: blog-api
ports:
- port: 80
targetPort: 8080
💡
Use Azure Kubernetes Service (AKS) or AWS EKS for managed Kubernetes. Managing your own control plane is rarely worth the operational overhead.
Health Checks
builder.Services.AddHealthChecks().AddDbContextCheck<BlogDbContext>();
app.MapHealthChecks("/health");