Bird
Raised Fist0
Azurecloud~20 mins

Deploying workloads to AKS in Azure - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
AKS Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Understanding Pod Scheduling in AKS

You deploy a workload to AKS with a pod that requests 2 CPU cores and 4 GB memory. The cluster has nodes with 1 CPU core and 3 GB memory each. What will happen when you apply the deployment?

AThe pod will remain pending because no single node has enough resources to satisfy the request.
BThe pod will be scheduled but will be throttled to fit the node resources.
CThe pod will be scheduled across multiple nodes to meet the resource request.
DThe pod will be scheduled on a single node because AKS automatically splits resource requests.
Attempts:
2 left
💡 Hint

Think about how Kubernetes schedules pods based on node resources.

Configuration
intermediate
2:00remaining
Correct YAML for Deploying a Container to AKS

Which YAML snippet correctly deploys a single container named webapp using the image nginx:latest in AKS?

A
apiVersion: v1
kind: Pod
metadata:
  name: webapp
spec:
  containers:
  - name: webapp
    image: nginx:latest
B
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: webapp
    spec:
      containers:
      - name: webapp
        image: nginx:latest
C
apiVersion: apps/v1
kind: Pod
metadata:
  name: webapp
spec:
  containers:
  - name: webapp
    image: nginx:latest
D
apiVersion: v1
kind: Deployment
metadata:
  name: webapp
spec:
  replicas: 1
  containers:
  - name: webapp
    image: nginx:latest
Attempts:
2 left
💡 Hint

Deployments use apps/v1 and have a template section.

Architecture
advanced
2:00remaining
Designing AKS Cluster for High Availability

You need to design an AKS cluster that remains available even if one node fails. Which configuration best supports this requirement?

ACreate one node pool with 3 nodes all in the same availability zone.
BCreate a single node pool with 1 node and enable auto-scaling.
CCreate three node pools each with 1 node in the same availability zone.
DCreate a single node pool with 3 nodes spread across 3 availability zones.
Attempts:
2 left
💡 Hint

Think about spreading nodes to avoid single points of failure.

security
advanced
2:00remaining
Securing Container Images in AKS

You want to ensure only trusted container images are deployed to your AKS cluster. Which approach enforces this best?

AAllow any image from public registries to speed up deployment.
BManually review images before deployment without automation.
CUse Azure Policy to enforce image source and scan images for vulnerabilities.
DUse Kubernetes Network Policies to restrict image downloads.
Attempts:
2 left
💡 Hint

Consider automated policies and scanning tools.

Best Practice
expert
2:00remaining
Optimizing AKS Cluster Cost and Performance

You manage an AKS cluster with variable workloads. What is the best practice to optimize cost without sacrificing performance?

AUse cluster autoscaler with multiple node pools of different VM sizes and spot instances for non-critical workloads.
BUse a fixed-size node pool with the largest VM size to handle peak loads at all times.
CDisable autoscaling and manually add nodes during high demand periods.
DUse only spot instances for all workloads to minimize cost.
Attempts:
2 left
💡 Hint

Think about balancing cost savings and workload reliability.

Practice

(1/5)
1. What is the main purpose of using a Deployment in Azure Kubernetes Service (AKS)?
easy
A. To monitor the health of the AKS cluster nodes
B. To manage and maintain a specified number of app copies running
C. To expose the app to the internet
D. To store data persistently for the app

Solution

  1. Step 1: Understand Deployment role in AKS

    A Deployment ensures that a specified number of replicas of an app are running and manages updates to those replicas.
  2. Step 2: Differentiate from other components

    Persistent storage is handled by volumes, exposure by Services, and monitoring by Azure Monitor, not Deployments.
  3. Final Answer:

    To manage and maintain a specified number of app copies running -> Option B
  4. Quick Check:

    Deployment manages app replicas = A [OK]
Hint: Deployments keep app copies running smoothly [OK]
Common Mistakes:
  • Confusing Deployment with Service for exposure
  • Thinking Deployment stores data
  • Assuming Deployment monitors nodes
2. Which kubectl command correctly applies a YAML file named app-deployment.yaml to deploy an app to AKS?
easy
A. kubectl create app-deployment.yaml
B. kubectl run app-deployment.yaml
C. kubectl apply -f app-deployment.yaml
D. kubectl deploy app-deployment.yaml

Solution

  1. Step 1: Identify correct kubectl syntax for applying YAML

    The command to apply a YAML file is kubectl apply -f filename.yaml.
  2. Step 2: Check other options for correctness

    kubectl create requires resource type, kubectl run is for quick pod creation, and kubectl deploy is not a valid command.
  3. Final Answer:

    kubectl apply -f app-deployment.yaml -> Option C
  4. Quick Check:

    Apply YAML file = kubectl apply -f [OK]
Hint: Use 'kubectl apply -f' to deploy YAML files [OK]
Common Mistakes:
  • Using 'kubectl create' without resource type
  • Trying 'kubectl deploy' which doesn't exist
  • Confusing 'kubectl run' with applying YAML
3. Given this YAML snippet for an AKS Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: nginx:latest
        ports:
        - containerPort: 80

How many pods will AKS try to run for this Deployment?
medium
A. 3
B. 2
C. 1
D. 0

Solution

  1. Step 1: Identify the replicas count in the YAML

    The replicas field is set to 3, meaning AKS will run 3 pods.
  2. Step 2: Confirm no other fields override replicas

    There is no override or scaling specified, so the number remains 3.
  3. Final Answer:

    3 -> Option A
  4. Quick Check:

    replicas: 3 means 3 pods [OK]
Hint: Check 'replicas' field for pod count [OK]
Common Mistakes:
  • Ignoring the replicas field
  • Confusing selector labels with pod count
  • Assuming default pod count is 1
4. You applied a Deployment YAML but your pods are stuck in 'Pending' state. Which of these is the most likely cause?
medium
A. The container image name is misspelled
B. The Service type is set to ClusterIP
C. The Deployment YAML is missing the 'replicas' field
D. There are not enough cluster resources to schedule pods

Solution

  1. Step 1: Understand what 'Pending' pod state means

    Pods in 'Pending' usually wait for resources like CPU or memory to be available on nodes.
  2. Step 2: Evaluate options for causing Pending state

    Misspelled image causes ImagePull errors, missing replicas defaults to 1, and Service type doesn't affect pod scheduling.
  3. Final Answer:

    There are not enough cluster resources to schedule pods -> Option D
  4. Quick Check:

    Pending pods = resource shortage [OK]
Hint: Pending pods often mean no resources available [OK]
Common Mistakes:
  • Confusing image pull errors with Pending state
  • Thinking missing replicas stops pod creation
  • Assuming Service type affects pod scheduling
5. You want to expose your AKS Deployment to the internet with a stable IP and load balancing. Which Kubernetes Service type should you use in your YAML?
hard
A. LoadBalancer
B. NodePort
C. ClusterIP
D. ExternalName

Solution

  1. Step 1: Identify Service types and their purposes

    ClusterIP exposes service inside cluster only, NodePort exposes on node ports, LoadBalancer creates cloud load balancer with stable IP, ExternalName maps to external DNS.
  2. Step 2: Choose Service type for internet exposure with stable IP

    LoadBalancer is the correct choice to get a cloud-managed IP and load balancing for external access.
  3. Final Answer:

    LoadBalancer -> Option A
  4. Quick Check:

    Internet exposure with stable IP = LoadBalancer [OK]
Hint: Use LoadBalancer Service for external stable IP [OK]
Common Mistakes:
  • Using ClusterIP which is internal only
  • Choosing NodePort which uses random ports
  • Confusing ExternalName with load balancing