Lesson 1 of 3 Deploying Applications to Azure Kubernetes Service

Understanding Azure Kubernetes Service

This lesson explains what Kubernetes and AKS do, the cluster objects developers use, how to connect with kubectl, and how clusters pull from ACR.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the declarative model of Kubernetes.
  • Distinguish the control plane, node pools and Pods.
  • Explain how attaching ACR grants pull access.
  • Choose between AKS and Container Apps.

What Kubernetes and AKS do

Kubernetes is an open-source orchestrator for containers. A developer tells it the desired state, such as three replicas of an API image with given resources and configuration, and Kubernetes continuously works to make the actual state match: it schedules containers onto machines, restarts them when they fail, replaces them during updates and routes traffic to them. This declarative model is the main difference from running containers by hand.

Azure Kubernetes Service runs the Kubernetes control plane (the API server, scheduler and controllers) as a managed service, and runs the nodes that host containers as Azure virtual machines in the customer's subscription. Microsoft patches and operates the control plane; the customer chooses node sizes, upgrades the cluster's Kubernetes version and pays for the nodes. Compared with Container Apps, AKS exposes the full Kubernetes API, which allows custom controllers, operators, Helm charts and detailed networking at the cost of more operational responsibility.

The following diagram maps each workload requirement to the part of an AKS design that meets it.

How workload requirements lead to AKS and its configuration. A vendor Kubernetes operator and existing Helm charts need the full Kubernetes API, which Container Apps does not expose. The reranker runs in a GPU user node pool, --attach-acr gives the kubelet identity AcrPull so no pull secret is stored, and workload identity lets Pods reach Azure data stores without secrets.
The requirements are typical examples.
Sort into groups

Who runs what in AKS?

Exam skills 1.2.3

Decide whether Microsoft or the customer is responsible for each part of an AKS cluster.

Log in to try this activity Interactive activities are free with an account.

Clusters, node pools and Pods

A cluster contains one or more node pools, groups of virtual machines of the same size. A system node pool runs critical cluster components such as CoreDNS; user node pools run application workloads and can use different VM sizes, such as GPU sizes for inference or Arm64 sizes for cost efficiency. The cluster autoscaler can add and remove nodes in a pool as demand changes.

The smallest unit that Kubernetes runs is a Pod: one or more containers that share a network address and storage volumes and are always scheduled together. Pods are disposable; when a node fails or a Deployment is updated, Pods are replaced with new ones that have new IP addresses. Higher-level objects, described in the next topic, create and manage Pods so that applications never depend on a particular Pod.

Namespaces divide a cluster into named groups of objects, such as orders and search. Names must be unique only within a namespace, and access control, quotas and network policies can be applied per namespace.

Match the pairs

Kubernetes building blocks

Exam skills 1.2.3

Match each Kubernetes or AKS term with its description.

Log in to try this activity Interactive activities are free with an account.

Connecting with kubectl

Developers manage Kubernetes objects through the Kubernetes API, usually with the kubectl command-line tool, which is preinstalled in Azure Cloud Shell. az aks get-credentials writes the cluster's connection details to the kubeconfig file, after which kubectl commands target that cluster. When the cluster uses Microsoft Entra ID integration with Azure RBAC for Kubernetes, the user also needs a role such as Azure Kubernetes Service RBAC Writer on the cluster or a namespace.

az aks get-credentials --resource-group RG --name CLUSTER
kubectl get nodes
kubectl get namespaces
kubectl config current-context

kubectl commands follow a regular pattern of verb, resource type and name, such as kubectl get pods, kubectl describe deployment orders-api or kubectl delete service orders-api. The -n option selects a namespace, and -o yaml prints an object's full definition.

Pulling images from ACR

Nodes pull images with the cluster's kubelet identity, a managed identity created with the cluster. Attaching a registry to the cluster grants that identity AcrPull on the registry, after which manifests can reference images such as REGISTRY.azurecr.io/orders-api:7f3c2ab with no pull secret.

az aks create --resource-group RG --name CLUSTER --node-count 2 --attach-acr REGISTRY --generate-ssh-keys
az aks update --resource-group RG --name CLUSTER --attach-acr REGISTRY

The first command attaches the registry when the cluster is created; the second attaches it to an existing cluster. The alternative, an imagePullSecrets entry that holds registry credentials, is needed only for registries outside the cluster's Microsoft Entra tenant or for clusters without managed identity.

Identities for application code

Pods that call Azure services, such as Cosmos DB or Key Vault, should use Microsoft Entra Workload ID: a Kubernetes service account is federated with a managed identity, and the Azure SDK's DefaultAzureCredential in the Pod obtains tokens for that identity with no secret. The kubelet identity is only for pulling images.

Scenario questions

Identities in AKS

Exam skills 1.2.3

Choose the identity or mechanism that fits each AKS requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing AKS for a workload

A team runs a retrieval service, an embedding worker and a GPU-based reranking model. The reranker needs a specific GPU VM size, a vendor-supplied Kubernetes operator manages the model's lifecycle, and the platform team already uses Helm charts for its other services. Images are stored in ACR, and stored credentials are forbidden.

The requirement for a third-party operator and existing Helm charts needs the full Kubernetes API, which points to AKS rather than Container Apps. The reranker runs in a user node pool with the required GPU size, and the other services in a general-purpose pool. Attaching the registry with --attach-acr grants the kubelet identity AcrPull, so no pull secret is stored, and the services reach Azure data stores through workload identity.

Container Apps offers GPU workload profiles and KEDA scaling, but it does not allow custom operators. Storing the registry admin password in an imagePullSecret would break the no-stored-credentials rule.

Check yourself

Which identity pulls images when AKS runs a Pod, and how does attaching ACR authorize it?

Show answer

The cluster's kubelet identity. --attach-acr assigns it the AcrPull role on the registry, so no imagePullSecret is needed.

Exam Tips

Remember for the exam

  • AKS manages the control plane; you choose, pay for and upgrade the node pools.
  • Attach ACR to give the kubelet identity AcrPull; no imagePullSecrets needed.
  • Application Pods use Microsoft Entra Workload ID to call Azure services.
  • Choose AKS over Container Apps when the full Kubernetes API is required.