Deploy to AKS with Manifest Files
30-second answer
On Azure Kubernetes Service (AKS) you describe your app in YAML manifest files and send them with kubectl apply -f. A Deployment says which image to run, how many replicas, which resources, probes and environment variables. A Service gives the pods a stable address (ClusterIP inside the cluster, LoadBalancer for a public IP). Kubernetes keeps the real state equal to what you declared, so a dead pod is replaced and a new image tag rolls out pod by pod.
Exam objective: 1.2.3 Deploy and manage applications to Azure Kubernetes Service (AKS) by using manifest files. (Skills measured as of October 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open the cluster. Under <strong>Kubernetes resources</strong>, select <strong>Workloads</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open the cluster. Under Kubernetes resources, select Workloads.
- Only system workloads so far. Select + Create → Apply a YAML.
- The manifest asks for 3 replicas of the image and a LoadBalancer Service in front of them. Kubernetes keeps reality matching it.
- 3/3 ready. Open chat-api to see its pods.
- Now break something. Select one pod and Delete it.
- A new pod appears straight away. You never restart pods by hand; you declare how many you want.
- The Service got a public IP from Azure Load Balancer and spreads requests over all healthy pods.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
AKS runs what the manifest says
On AKS you describe the app in YAML manifests: a Deployment (image, replicas, probes, resources) and a Service (a stable address). kubectl apply -f sends them. Kubernetes keeps the real state equal to what you declared.
🤔 What happens if…
Read this tour as text
- Build an image, push it to the registry. Your Python API and everything it needs are packed into a container image. You push it to Azure Container Registry (ACR) as
ragapi:1.4.0. A tag names a version. A digest (sha256:…) names the exact bytes and never changes. - ACR Tasks build in the cloud. ACR Tasks build the image inside Azure, so you don’t need Docker on your laptop.
az acr buildis a quick task. A task can also run on every git commit or when the base image (saypython:3.12-slim) gets a security patch. - App Service runs one container. App Service pulls the image and runs it. App settings become environment variables inside the container. A setting can be a Key Vault reference, so the secret never sits in the image or in the portal in plain text.
- Container Apps environment. An Azure Container Apps environment is a secure boundary with its own virtual network and Log Analytics workspace. Several container apps share it. Ingress decides who can reach each app: external (internet) or internal (only the environment).
- Revisions and traffic splitting. Every change to the template (image, env vars, scale rules) creates a new revision, an immutable snapshot. In multiple revision mode you can send 80% of traffic to the old one and 20% to the new one, then roll forward or back.
- KEDA scales on events. Container Apps uses KEDA scale rules. A Service Bus rule adds replicas as the queue grows (for example one replica per 5 messages), up to max replicas. When the queue empties, it scales back to min replicas, which can be zero.
- AKS runs what the manifest says. On AKS you describe the app in YAML manifests: a Deployment (image, replicas, probes, resources) and a Service (a stable address).
kubectl apply -fsends them. Kubernetes keeps the real state equal to what you declared. - Troubleshoot: logs, events, connectivity. When it breaks, look in three places. Logs (
kubectl logs,az containerapp logs show) show what the app said. Events (kubectl describe,kubectl get events) show what the platform did. Connectivity checks (DNS, ports, ingress) show whether traffic can reach it.
Deploy a small API to Kubernetes with manifests, watch it heal itself, then hit the two failures every developer meets: an image that doesn't exist and a container that crashes on start. Use describe, logs and rollout to fix them.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Someone changed a setting by hand on the cluster and nobody knows what.
😊 THE SOLUTION
Describe the app in YAML manifests and kubectl apply them.
- Hand-made changes✓ Declarative YAML in git
- A pod dies at 3 AM✓ The Deployment replaces it
- Pods change IPs✓ A Service gives a stable name
Start with a question
How do you tell 30 servers to run three copies of your API, and keep it that way?
You could log in to each machine, start containers and restart them when they die. That’s fine for one server and miserable for thirty.
On AKS, you write down what you want in a manifest: “three copies of ragapi:1.4.0, 0.5 CPU each, reachable on port 80”. You hand it to Kubernetes with kubectl apply, and Kubernetes keeps making it true.
Explain it like I’m 10
Visual: Kubernetes desired state in motion
See a Deployment and Service go in with kubectl apply, then watch Kubernetes replace a dead pod and hold the line when an image is bad.
Read the video script
- Write down what you wantOn AKS you don't start containers by hand. You write down what you want in a YAML manifest. This Deployment says: three copies of ragapi one point four, and here's the health check for each one.
- A Service gives one stable addressPods come and go, so callers need one address that doesn't change. That's the Service. It finds the pods by their label, and the LoadBalancer type gets a public IP from Azure.
- kubectl applyNow you hand it over with kubectl apply. Kubernetes places three pods on the nodes, each node pulls the image from your registry, and pods that pass the readiness probe join the Service.
- A loop keeps checkingAnd Kubernetes doesn't stop there. A controller keeps comparing what you asked for with what's really running. Right now they match, three and three, so it does nothing.
- A pod dies, a new one appearsNow a pod crashes. Ready drops to two, which doesn't match three. The controller notices and starts a replacement on its own. Nobody had to log in or restart anything.
- A bad image: ImagePullBackOffNext, someone changes the image to version one point five, but that tag was never pushed. The new pod can't pull it, so it shows ImagePullBackOff and keeps retrying. The rolling update waits, and the three old pods keep serving users.
- Undo, and you’re backTo fix it, roll back with kubectl rollout undo, or correct the tag in the YAML and apply it again. The broken pod is removed, and you're back to three healthy copies of the version that works.
The technical explanation
Cluster and access
az aks create --resource-group rg-ai --name aks-rag \
--node-count 2 --attach-acr myreg --generate-ssh-keys
az aks get-credentials --resource-group rg-ai --name aks-rag
kubectl get nodes
--attach-acr assigns AcrPull to the cluster’s kubelet identity, so pods pull from myreg.azurecr.io without secrets. For an existing cluster: az aks update -n aks-rag -g rg-ai --attach-acr myreg.
The manifest
# ragapi.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ragapi
spec:
replicas: 3
selector:
matchLabels:
app: ragapi
template:
metadata:
labels:
app: ragapi # must match the selector above
spec:
containers:
- name: ragapi
image: myreg.azurecr.io/ragapi:1.4.0
ports:
- containerPort: 8000
env:
- name: MODEL_DEPLOYMENT
value: gpt-4.1-mini
- name: SEARCH_KEY
valueFrom:
secretKeyRef:
name: rag-secrets
key: search-key
resources:
requests: { cpu: 250m, memory: 512Mi }
limits: { cpu: 500m, memory: 1Gi }
readinessProbe:
httpGet: { path: /healthz, port: 8000 }
livenessProbe:
httpGet: { path: /healthz, port: 8000 }
initialDelaySeconds: 15
---
apiVersion: v1
kind: Service
metadata:
name: ragapi
spec:
type: LoadBalancer
selector:
app: ragapi
ports:
- port: 80
targetPort: 8000
The Service’s selector finds pods labelled app: ragapi. port is what callers use, targetPort is the container’s port. ClusterIP (the default) is reachable only inside the cluster; LoadBalancer asks Azure for a public IP on the cluster’s load balancer.
Apply and check
kubectl create secret generic rag-secrets --from-literal=search-key="$SEARCH_KEY"
kubectl apply -f ragapi.yaml
kubectl get deployments,pods,services
kubectl get service ragapi --watch # wait for EXTERNAL-IP
Roll out a new version
kubectl set image deployment/ragapi ragapi=myreg.azurecr.io/ragapi:1.5.0
kubectl rollout status deployment/ragapi
kubectl rollout undo deployment/ragapi # if 1.5.0 misbehaves
kubectl scale deployment/ragapi --replicas=5
In a real pipeline you’d change the tag in the YAML and kubectl apply again, so the file in git always matches the cluster.
-
1 Declare
kubectl apply sends the Deployment and Service to the API server.
-
2 Schedule
The scheduler places 3 pods on nodes with room for their requests.
-
3 Pull and start
Each node pulls the image from ACR and starts the container.
-
4 Ready
Pods passing the readiness probe join the Service.
Architect level Keeping secrets in Key Vault on AKS
A Kubernetes Secret is only base64-encoded and sits in the cluster’s store. The Azure Key Vault provider for Secrets Store CSI Driver (az aks enable-addons --addons azure-keyvault-secrets-provider) mounts Key Vault secrets as files, and can sync them to a Kubernetes Secret if you need env vars. With Microsoft Entra Workload ID, the pod’s service account is federated with a managed identity that has access to the vault, so there’s no credential in the cluster at all. The same identity can call Azure OpenAI or Cosmos DB with DefaultAzureCredential.
Real-world business scenario
Proseware Media (fictional)
- The problem
- A recommendation API and three model-serving services ran on VMs with hand-written start scripts. A crashed process stayed down until someone noticed.
- What they used
- AKS with --attach-acr, a Deployment and Service manifest per service in git, readiness and liveness probes, and the Key Vault CSI driver for model keys.
- Why that choice
- Kubernetes replaces failed pods on its own, probes stop broken versions taking traffic, and the YAML in git is the record of what runs.
- The result
- Crashed pods restart in seconds, and releases are a reviewed change to a manifest.
When to use it and when not to
✓ Use it when…
- You need the Kubernetes API: custom controllers, operators, Helm charts or service meshes.
- You need GPU node pools or fine control over nodes for model serving.
- Many teams share one platform with namespaces and policies.
✕ Think twice when…
- One or two APIs with no special Kubernetes needs; Container Apps is less to run.
- Teams without time to own cluster upgrades, node patching and security.
↔ Alternatives to consider
- Azure Container Apps for Kubernetes-style containers without managing a cluster.
- AKS Automatic for a cluster with node management and best-practice settings handled for you.
Test yourself with exercises
5 original practice questions in the AI-200 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between a Deployment and a Service?
Model answer
The Deployment runs the pods: image, replica count, resources. The Service is the front door: one stable address that forwards to whichever pods match its label selector. Pods come and go, the Service address stays.
Intermediate How does AKS get permission to pull images from your ACR?
Model answer
I run az aks create or az aks update with --attach-acr myreg. That assigns AcrPull on the registry to the cluster's kubelet managed identity, so no imagePullSecrets are needed.
Experienced developer How do you roll out a new image and roll back if it's bad?
Model answer
I change the image tag in the manifest and kubectl apply it, or use kubectl set image. The Deployment does a rolling update, replacing pods gradually and only counting new pods once their readiness probe passes. kubectl rollout status shows progress and kubectl rollout undo goes back to the previous ReplicaSet.
Interviewer follows up
Why do probes matter there?
You
Without a readiness probe, Kubernetes sends traffic to a pod as soon as the container starts, even if the model client isn't ready, and a broken version can roll out completely.
Scenario The model endpoint key must reach the pods. Where do you put it?
Model answer
Not in the manifest or the image. A Kubernetes Secret at minimum, referenced with secretKeyRef. Better, the Secrets Store CSI Driver with the Azure Key Vault provider and workload identity, so the value stays in Key Vault.
Quick revision
Key points
- az aks get-credentials writes kubeconfig so kubectl can talk to the cluster.
- --attach-acr gives the kubelet identity AcrPull on the registry.
- A Deployment declares image, replicas, resources, probes and env; its selector must match the pod template labels.
- A Service selects pods by label; ClusterIP is internal, LoadBalancer gets an Azure public IP.
- kubectl apply -f creates or updates; rollout status and rollout undo manage releases.
Important terminology
- Manifest
- A YAML file that declares a Kubernetes object, such as a Deployment or Service, and its desired state.
- Deployment
- A Kubernetes object that keeps a set number of identical pods running and rolls out new versions.
- Pod
- The smallest unit Kubernetes runs; one or more containers that share a network address.
- Service
- A stable name and IP in front of a set of pods, selected by labels.
- kubectl apply
- The command that creates or updates objects so they match the manifest.
- Readiness probe
- A check that decides whether a pod receives traffic from its Service.
Common mistakes
- A Service selector that doesn't match the pod labels, so the Service has no endpoints.
- Putting secrets as plain env values in the manifest and committing it.
Exam tips
- "Expose the app with a public IP" = Service type: LoadBalancer.
- "Reachable only inside the cluster" = ClusterIP (the default).
- "Pull from ACR without image pull secrets" = az aks update --attach-acr.
Five quick revision questions
-
1.Which command sends a manifest to the cluster?Show
kubectl apply -f ragapi.yaml
-
2.Which object keeps N copies of a pod running?Show
A Deployment.
-
3.What is the default Service type?Show
ClusterIP.
-
4.How do you roll back a Deployment?Show
kubectl rollout undo deployment/ragapi
-
5.Which command gets AKS credentials for kubectl?Show
az aks get-credentials
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Troubleshoot AKS and Container Apps: Logs, Events, Connectivity
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.