CKA · Domain 2 of 5 · 15% of the exam

CKA Domain 2: Workloads and Scheduling

31 free practice questions for Workloads and Scheduling in the Certified Kubernetes Administrator (CKA) exam. Try each question first, then open "Show answer" for the correct option and explanation.

Workloads and Scheduling practice questions

  1. Question 1. Which command changes the image of the nginx container in Deployment web to nginx:1.27?

    1. kubectl edit pod web --image=nginx:1.27
    2. kubectl set image deployment/web nginx=nginx:1.27
    3. kubectl rollout image web nginx:1.27
    4. kubectl replace deployment web nginx:1.27
    Show answer

    Answer: B. kubectl set image deployment/web nginx=nginx:1.27

    set image triggers a rolling update of the Deployment's Pods.

  2. Question 2. A new Deployment revision is failing. Which command returns to the previous revision?

    1. kubectl rollout restart deployment/web
    2. kubectl delete deployment web --previous
    3. kubectl rollout undo deployment/web
    4. kubectl scale deployment web --revision=-1
    Show answer

    Answer: C. kubectl rollout undo deployment/web

    rollout undo reverts to the previous revision. --to-revision picks a specific one.

  3. Question 3. Which command shows the revision history of a Deployment?

    1. kubectl rollout history deployment/web
    2. kubectl get revisions web
    3. kubectl describe history web
    4. kubectl logs deployment/web --history
    Show answer

    Answer: A. kubectl rollout history deployment/web

    History lists revisions, with change causes if annotated.

  4. Question 4. In a RollingUpdate strategy, what does maxUnavailable: 0 with maxSurge: 1 mean?

    1. A new Pod starts before an old one stops, so capacity never drops
    2. All old Pods are removed before any new ones start
    3. Only one Pod in total may run during the update
    4. The update pauses until someone resumes it manually
    Show answer

    Answer: A. A new Pod starts before an old one stops, so capacity never drops

    maxSurge allows extra Pods above the desired count, and maxUnavailable limits how many can be down.

  5. Question 5. Which Deployment strategy terminates all old Pods before creating new ones?

    1. RollingUpdate
    2. BlueGreen
    3. Recreate
    4. Canary
    Show answer

    Answer: C. Recreate

    Recreate causes downtime but ensures old and new versions never run at the same time.

  6. Question 6. Which object stores non-sensitive configuration, such as an application's settings file?

    1. Secret
    2. PersistentVolume
    3. ServiceAccount
    4. ConfigMap
    Show answer

    Answer: D. ConfigMap

    ConfigMaps hold configuration data. Secrets are for sensitive values.

  7. Question 7. How are values in a Kubernetes Secret stored in its manifest by default?

    1. Base64-encoded, which is not encryption
    2. AES-encrypted with the cluster key
    3. Hashed with SHA-256
    4. In plain text only
    Show answer

    Answer: A. Base64-encoded, which is not encryption

    Base64 is only encoding. Enable encryption at rest in etcd and restrict RBAC access to Secrets.

  8. Question 8. Which command creates a Secret with a password key from the command line?

    1. kubectl create secret generic db --from-literal=password=S3cret
    2. kubectl create configmap db --secret password=S3cret
    3. kubectl create secret tls db --password=S3cret
    4. kubectl set secret db password=S3cret
    Show answer

    Answer: A. kubectl create secret generic db --from-literal=password=S3cret

    generic Secrets accept --from-literal, --from-file, or --from-env-file.

  9. Question 9. How can every key in ConfigMap app-config become environment variables in a container?

    1. Use volumeMounts with the ConfigMap name only
    2. Use env with valueFrom: secretKeyRef
    3. Use a hostPath volume to the ConfigMap
    4. Use envFrom with configMapRef: name: app-config
    Show answer

    Answer: D. Use envFrom with configMapRef: name: app-config

    envFrom imports all keys. env with valueFrom picks individual keys.

  10. Question 10. A ConfigMap is mounted as a volume. What happens when the ConfigMap is updated?

    1. The Pod is restarted automatically
    2. Nothing changes until the node reboots
    3. The Pod is deleted and recreated immediately
    4. The mounted files are updated after a short delay
    Show answer

    Answer: D. The mounted files are updated after a short delay

    Volume-mounted ConfigMaps refresh eventually. Environment variables don't update until the Pod restarts.

  11. Question 11. Which object automatically scales the number of Pods in a Deployment based on CPU usage?

    1. HorizontalPodAutoscaler
    2. VerticalPodAutoscaler
    3. ResourceQuota
    4. PodDisruptionBudget
    Show answer

    Answer: A. HorizontalPodAutoscaler

    HPA changes replica counts. VPA adjusts resource requests of the Pods.

  12. Question 12. Which command creates an HPA for Deployment web targeting 70% CPU, between 2 and 10 replicas?

    1. kubectl scale deployment web --cpu=70 --min=2 --max=10
    2. kubectl create hpa web --target=70
    3. kubectl set autoscale web 2-10
    4. kubectl autoscale deployment web --cpu-percent=70 --min=2 --max=10
    Show answer

    Answer: D. kubectl autoscale deployment web --cpu-percent=70 --min=2 --max=10

    kubectl autoscale creates a HorizontalPodAutoscaler object.

  13. Question 13. An HPA shows <unknown> for current CPU usage. What is the MOST likely cause?

    1. The Deployment uses the Recreate strategy
    2. The metrics server isn't installed or Pods have no CPU requests
    3. The Service type is ClusterIP
    4. The namespace has no NetworkPolicy
    Show answer

    Answer: B. The metrics server isn't installed or Pods have no CPU requests

    HPA needs resource metrics and CPU requests to calculate utilization percentages.

  14. Question 14. What does a liveness probe do when it fails repeatedly?

    1. The Pod is removed from Service endpoints only
    2. The node is marked NotReady
    3. The kubelet restarts the container
    4. The Deployment is rolled back
    Show answer

    Answer: C. The kubelet restarts the container

    Liveness probes detect stuck containers. Readiness probes control whether a Pod receives traffic.

  15. Question 15. What happens when a readiness probe fails?

    1. The container is restarted immediately
    2. The Pod is rescheduled to another node
    3. The Pod is removed from Service endpoints until it passes
    4. The image is pulled again
    Show answer

    Answer: C. The Pod is removed from Service endpoints until it passes

    Readiness gates traffic without restarting the container.

  16. Question 16. An application takes up to 3 minutes to start. Which probe prevents the liveness probe from killing it during startup?

    1. A readiness probe with a short period
    2. A startup probe
    3. An exec liveness probe
    4. A PreStop hook
    Show answer

    Answer: B. A startup probe

    Liveness and readiness checks wait until the startup probe succeeds.

  17. Question 17. What is the difference between resource requests and limits?

    1. Limits are used for scheduling; requests cap usage
    2. Requests are used for scheduling; limits cap what a container can use
    3. Both are only used for billing
    4. Requests apply to nodes; limits apply to namespaces
    Show answer

    Answer: B. Requests are used for scheduling; limits cap what a container can use

    The scheduler places Pods based on requests. Exceeding a memory limit gets the container OOM-killed.

  18. Question 18. A container exceeds its memory limit. What happens?

    1. It is terminated with OOMKilled
    2. It is throttled but keeps running
    3. It is moved to another node
    4. Its limit is raised automatically
    Show answer

    Answer: A. It is terminated with OOMKilled

    Memory can't be throttled, so exceeding the limit kills the container. CPU over the limit is throttled.

  19. Question 19. Which field schedules a Pod only onto nodes labeled disktype=ssd, in its simplest form?

    1. tolerations: disktype=ssd
    2. nodeName: disktype-ssd
    3. affinity: podAntiAffinity
    4. nodeSelector: {disktype: ssd}
    Show answer

    Answer: D. nodeSelector: {disktype: ssd}

    nodeSelector is the simplest node constraint. Node affinity provides more expressive rules.

  20. Question 20. Which feature lets a Pod prefer, but not require, nodes in a specific zone?

    1. requiredDuringSchedulingIgnoredDuringExecution node affinity
    2. A nodeSelector with the zone label
    3. A taint on the other nodes
    4. preferredDuringSchedulingIgnoredDuringExecution node affinity
    Show answer

    Answer: D. preferredDuringSchedulingIgnoredDuringExecution node affinity

    Preferred rules add weight to matching nodes. Required rules must be satisfied.

  21. Question 21. A node has the taint gpu=true:NoSchedule. Which Pods can be scheduled on it?

    1. Only Pods with a matching toleration
    2. Any Pod, because taints are advisory
    3. Only DaemonSet Pods, regardless of tolerations
    4. No Pods at all, ever
    Show answer

    Answer: A. Only Pods with a matching toleration

    Taints repel Pods without a matching toleration. A toleration allows, but doesn't force, scheduling there.

  22. Question 22. Which taint effect also evicts running Pods that don't tolerate it?

    1. NoExecute
    2. NoSchedule
    3. PreferNoSchedule
    4. NoEvict
    Show answer

    Answer: A. NoExecute

    NoExecute affects running Pods. NoSchedule affects only new scheduling decisions.

  23. Question 23. Which command removes the taint gpu=true:NoSchedule from node1?

    1. kubectl taint nodes node1 gpu=true:NoSchedule-
    2. kubectl untaint node1 gpu
    3. kubectl taint nodes node1 gpu=false
    4. kubectl delete taint node1 gpu
    Show answer

    Answer: A. kubectl taint nodes node1 gpu=true:NoSchedule-

    Adding a trailing minus sign removes the taint.

  24. Question 24. Which workload type runs one Pod on every node, for example a log collector?

    1. DaemonSet
    2. Deployment
    3. StatefulSet
    4. Job
    Show answer

    Answer: A. DaemonSet

    DaemonSets add a Pod when a node joins and remove it when the node leaves.

  25. Question 25. Which workload type gives Pods stable names and persistent storage per replica, such as db-0 and db-1?

    1. Deployment
    2. ReplicaSet
    3. DaemonSet
    4. StatefulSet
    Show answer

    Answer: D. StatefulSet

    StatefulSets provide ordered deployment, stable network identities, and volumeClaimTemplates.

  26. Question 26. Which object runs a task to completion, such as a database migration?

    1. Deployment
    2. DaemonSet
    3. Service
    4. Job
    Show answer

    Answer: D. Job

    Jobs run Pods until they complete successfully. CronJobs run Jobs on a schedule.

  27. Question 27. Which object runs a Job every night at 2 a.m.?

    1. CronJob with schedule "0 2 * * *"
    2. Job with a sleep command
    3. Deployment with restartPolicy Never
    4. DaemonSet with a timer
    Show answer

    Answer: A. CronJob with schedule "0 2 * * *"

    CronJobs use standard cron syntax to create Jobs on a schedule.

  28. Question 28. What sets default CPU and memory requests for containers that don't specify them in a namespace?

    1. A LimitRange
    2. A ResourceQuota
    3. A PriorityClass
    4. A NetworkPolicy
    Show answer

    Answer: A. A LimitRange

    LimitRange sets defaults and min/max values. ResourceQuota caps the namespace's total usage.

  29. Question 29. What does a ResourceQuota do in a namespace?

    1. Sets default requests for every container
    2. Restricts network traffic between the Pods
    3. Assigns the namespace's Pods to specific nodes
    4. Caps total resource use and object counts
    Show answer

    Answer: D. Caps total resource use and object counts

    Quotas prevent one team from consuming all cluster resources.

  30. Question 30. Which Pod field makes the scheduler bypass normal scheduling and place the Pod on a specific node?

    1. nodeSelector
    2. nodeName
    3. schedulerName
    4. hostname
    Show answer

    Answer: B. nodeName

    nodeName assigns the Pod directly. It's rarely used because it skips scheduler checks.

  31. Question 31. A Deployment must keep at least one replica of its Pods on each of three zones. Which Pod spec field spreads replicas evenly?

    1. tolerations
    2. priorityClassName
    3. terminationGracePeriodSeconds
    4. topologySpreadConstraints
    Show answer

    Answer: D. topologySpreadConstraints

    Topology spread constraints balance Pods across zones, nodes, or other topology domains using node labels.

CKA, Certified Kubernetes Administrator, and Kubernetes are trademarks of The Linux Foundation. These questions are original study material, not questions from the real exam.