Home › CKA › Topics › Practice tasks › Pod Priority & Preemption
CKA · Workloads & Scheduling

Pod Priority & Preemption

A Deployment named busybox-logger exists in the priority namespace. An existing user-defined PriorityClass user-existing has value 10000.

Check live lab access → All CKA tasks

Live lab access

This task description is public. Its live lab requires full access; six other CKA labs are available in Free Practice with AI Lab Coach.

Create an account to continue →

Explore the six free labs with AI Lab Coach →

Read the brief on any device. Use a desktop or laptop for the terminal lab. Nothing starts until you choose Start.

The task

A Deployment named busybox-logger exists in the priority namespace.

An existing user-defined PriorityClass user-existing has value 10000.

Task:

  1. Create a new PriorityClass named high-priority with a value one less than the highest existing user-defined value (i.e. 9999)
  2. Patch the busybox-logger Deployment to use high-priority

Original Prepium workshop · Tested on Kubernetes v1.35.0 on 1 October 2026 in a kind cluster with two workers. Use a disposable cluster: step 3 deliberately fills one worker's CPU requests so that the scheduler has to preempt a Pod.

PriorityClass: how a Pod gets its priority, and what preemption looks like

A PriorityClass is a cluster-scoped object that maps a name to an integer. A Pod refers to it by priorityClassName, and at admission Kubernetes copies the number into the Pod's spec.priority. The scheduler uses that number twice: higher-priority Pods are tried first, and when a high-priority Pod cannot fit anywhere, the scheduler may preempt (evict) lower-priority Pods to make room.

1. Read what already exists

kubectl get priorityclass

A fresh cluster has two built-in classes, system-cluster-critical (2000000000) and system-node-critical (2000001000), reserved for components the cluster cannot run without. User-defined classes must stay at or below 1000000000. Check the GLOBAL-DEFAULT column too: if a class has globalDefault: true, Pods without a priorityClassName get its value instead of 0.

2. Create two classes

Save this as priorityclasses.yaml:

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: tutorial-low
value: 1000
globalDefault: false
description: "Batch work that may be preempted."
---
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: tutorial-high
value: 100000
globalDefault: false
description: "Latency-sensitive work that may preempt lower priorities."
kubectl apply -f priorityclasses.yaml
kubectl get priorityclass

3. Watch a high-priority Pod preempt a low one

The Pods below are pinned to one worker and each requests 60% of its allocatable CPU, so the node cannot hold both. The scheduler decides by requests, not actual usage, which is why pause containers that use no CPU are enough.

kubectl create namespace prepium-tutorial
WORKER=$(kubectl get nodes -l '!node-role.kubernetes.io/control-plane' -o jsonpath='{.items[0].metadata.name}')
ALLOC=$(kubectl get node "$WORKER" -o jsonpath='{.status.allocatable.cpu}')
case "$ALLOC" in *m) ALLOC_M=${ALLOC%m};; *) ALLOC_M=$((ALLOC*1000));; esac
REQ=$((ALLOC_M*6/10))
for p in low:tutorial-low high:tutorial-high; do
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata: {name: ${p%%:*}, namespace: prepium-tutorial}
spec:
  priorityClassName: ${p#*:}
  nodeSelector: {kubernetes.io/hostname: $WORKER}
  containers:
  - name: pause
    image: registry.k8s.io/pause:3.10
    resources: {requests: {cpu: ${REQ}m}}
EOF
[ "${p%%:*}" = low ] && kubectl -n prepium-tutorial wait --for=condition=Ready pod/low
done
kubectl -n prepium-tutorial get pods -o wide --watch

Before the second Pod arrives, check kubectl -n prepium-tutorial get pod low -o jsonpath='{.spec.priority}': it prints 1000, copied from the class. Then high cannot fit, the scheduler evicts low, and high starts on the same node. The evidence is in the events: kubectl -n prepium-tutorial get events --field-selector reason=Preempted shows Preempted by pod ... on node .... A bare Pod that is preempted is gone for good; a Pod owned by a Deployment would be recreated and then sit Pending until room frees up.

4. Get the name wrong once

kubectl -n prepium-tutorial run ghost --image=registry.k8s.io/pause:3.10 \
  --overrides='{"spec":{"priorityClassName":"does-not-exist"}}'

A bare Pod is rejected at once: no PriorityClass with name does-not-exist was found. The same typo in a Deployment's Pod template is more dangerous, because the Deployment itself is accepted. The error surfaces only as a FailedCreate event on the ReplicaSet, while the Deployment quietly shows fewer ready replicas. After changing priorityClassName on a workload, check kubectl get events and the rollout, not just the apply output.

Changing the class on a Deployment also only affects new Pods. Priority is fixed when a Pod is admitted, so the template change triggers a rollout, and the new Pods carry the new value.

Example checkEvidence
Class exists with the intended valuekubectl get priorityclass VALUE column
Workload uses itpriorityClassName in the Pod template
Running Pods carry itCurrent Pods show the class value in spec.priority

Cleanup: kubectl delete namespace prepium-tutorial and kubectl delete -f priorityclasses.yaml (classes are cluster-scoped). Reference: Pod Priority and Preemption. Next, try taints and tolerations.

Exam
CKA
Domain
Workloads & Scheduling
Grading
Programmatic · partial credit

What this tests

Run and schedule workloads - deployments, autoscaling, taints and tolerations, affinity, and resource limits. On the CKA exam, Workloads & Scheduling tasks are graded purely on what you build in the cluster - not multiple choice - so the only way to get faster is to do them on a real cluster against a clock.

Practice it for real

The public description lets you study the task before signing up. Full access includes every live lab. Six selected CKA scenarios are included in Free Practice, with five shared sessions each week. You solve the task in a real terminal, hit validate, and a programmatic checker scores exactly what you got right and wrong (with partial credit). You can open the solution while practising, then retry and use the failed checks to improve your score.

Related CKA tasks