Bird
Raised Fist0
Kubernetesdevops~20 mins

Priority classes for critical workloads in Kubernetes - 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
🎖️
Priority Class Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding PriorityClass purpose

What is the main purpose of defining a PriorityClass in Kubernetes?

ATo configure persistent storage classes for pods
BTo assign a priority value to pods that influences scheduling and eviction order
CTo specify resource limits like CPU and memory for pods
DTo define network policies for pod communication
Attempts:
2 left
💡 Hint

Think about how Kubernetes decides which pods to keep or evict under resource pressure.

💻 Command Output
intermediate
1:30remaining
Output of kubectl get priorityclass

What is the output of the command kubectl get priorityclass if you have two priority classes named high-priority with value 1000 and low-priority with value 100?

A
NAME           VALUE   GLOBAL-DEFAULT   DESCRIPTION
high-priority  1000    false            High priority class
low-priority   100     false            Low priority class
B
NAME           VALUE   GLOBAL-DEFAULT   DESCRIPTION
high-priority  100     false            High priority class
low-priority   1000    false            Low priority class
C
NAME           VALUE   GLOBAL-DEFAULT   DESCRIPTION
low-priority   100     false            Low priority class
high-priority  1000    false            High priority class
DError: priorityclass not found
Attempts:
2 left
💡 Hint

Check the order and values of priority classes as listed by kubectl.

Configuration
advanced
2:00remaining
Correct PriorityClass YAML for critical workload

Which YAML snippet correctly defines a PriorityClass named critical with a value of 100000 and sets it as the global default?

A
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: critical
value: 100000
globalDefault: false
description: "Critical priority class"
B
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: critical
spec:
  value: 100000
globalDefault: true
description: "Critical priority class"
C
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: critical
value: "100000"
globalDefault: true
description: "Critical priority class"
D
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: critical
value: 100000
globalDefault: true
description: "Critical priority class"
Attempts:
2 left
💡 Hint

Remember that value is a top-level field, not under spec, and globalDefault must be true to set default.

Troubleshoot
advanced
1:30remaining
Pod scheduling failure due to PriorityClass

A pod with PriorityClass critical is stuck in Pending state. The cluster has resource pressure and other pods with lower priority are running. What is the most likely cause?

AThe pod's PriorityClass value is lower than other pods running
BThe pod's container image is missing
CThe PriorityClass <code>critical</code> is not defined in the cluster
DThe pod has resource requests higher than node capacity
Attempts:
2 left
💡 Hint

Check if the PriorityClass exists and is spelled correctly.

Best Practice
expert
2:00remaining
Choosing PriorityClass values for critical workloads

When assigning PriorityClass values for critical workloads, which practice is best to ensure proper scheduling and eviction behavior?

AAssign very high values (e.g., 1000000) to critical workloads and low values (e.g., 10) to others, ensuring clear priority separation
BUse the same PriorityClass value for all workloads to avoid scheduling conflicts
CAssign random values to PriorityClass to distribute scheduling evenly
DSet all PriorityClass values to zero and rely on resource requests for scheduling
Attempts:
2 left
💡 Hint

Think about how Kubernetes uses priority values to decide which pods to evict first.

Practice

(1/5)
1. What does a higher value in a Kubernetes PriorityClass mean?
easy
A. The pod will be scheduled on nodes with more memory.
B. The pod will use less CPU resources.
C. The pod has a higher priority and is more important.
D. The pod will restart automatically on failure.

Solution

  1. Step 1: Understand PriorityClass value meaning

    In Kubernetes, the value field in a PriorityClass defines the importance of the pod. Higher values mean higher priority.
  2. Step 2: Relate priority to pod importance

    Pods with higher priority are considered more critical and get scheduled before lower priority pods.
  3. Final Answer:

    The pod has a higher priority and is more important. -> Option C
  4. Quick Check:

    Higher value = higher priority [OK]
Hint: Higher PriorityClass value means more important pod [OK]
Common Mistakes:
  • Confusing priority with resource limits
  • Thinking priority controls pod restart behavior
  • Assuming priority affects node selection by memory
2. Which of the following is the correct YAML snippet to define a PriorityClass named high-priority with value 1000 and globalDefault: false?
easy
A. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: 1000 globalDefault: false description: "High priority class"
B. apiVersion: v1 kind: PriorityClass metadata: name: high-priority priority: 1000 default: false
C. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: 1000 globalDefault: true description: "High priority class"
D. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: "1000" globalDefault: false description: "High priority class"

Solution

  1. Step 1: Check correct apiVersion and kind

    The correct apiVersion for PriorityClass is scheduling.k8s.io/v1 and kind is PriorityClass.
  2. Step 2: Verify fields and types

    The field for priority is value (integer), not priority. globalDefault is a boolean. The value must be an integer, not a string.
  3. Final Answer:

    YAML with apiVersion scheduling.k8s.io/v1, kind PriorityClass, value 1000 as integer, globalDefault false -> Option A
  4. Quick Check:

    Correct apiVersion and value field [OK]
Hint: Use 'value' as integer and correct apiVersion [OK]
Common Mistakes:
  • Using wrong apiVersion or kind
  • Using 'priority' instead of 'value'
  • Setting value as string instead of integer
3. Given this PriorityClass YAML and pod spec, what priority value will the pod have?
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: critical
value: 2000
globalDefault: false
description: "Critical priority"

---

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  priorityClassName: critical
  containers:
  - name: app
    image: nginx
medium
A. 1000
B. 2000
C. 0
D. Pod will fail to schedule

Solution

  1. Step 1: Identify PriorityClass used by pod

    The pod specifies priorityClassName: critical, so it uses the PriorityClass named 'critical'.
  2. Step 2: Find priority value of 'critical'

    The PriorityClass 'critical' has value: 2000, so the pod's priority is 2000.
  3. Final Answer:

    2000 -> Option B
  4. Quick Check:

    Pod priority matches PriorityClass value [OK]
Hint: Pod priority equals PriorityClass value it references [OK]
Common Mistakes:
  • Assuming default priority 0 without PriorityClass
  • Confusing priorityClassName with container image
  • Thinking pod fails without globalDefault
4. You created a PriorityClass with globalDefault: true but pods without priorityClassName still have priority 0. What is the likely cause?
medium
A. The PriorityClass value is set to 0.
B. globalDefault only works for DaemonSets, not pods.
C. Pods must specify priorityClassName to get any priority.
D. The PriorityClass resource was not applied correctly.

Solution

  1. Step 1: Understand globalDefault behavior

    A PriorityClass with globalDefault: true sets the default priority for pods without a specified class.
  2. Step 2: Check why pods have priority 0

    If pods still have priority 0, likely the PriorityClass was not created or applied properly, so Kubernetes does not see it as default.
  3. Final Answer:

    The PriorityClass resource was not applied correctly. -> Option D
  4. Quick Check:

    globalDefault requires correct PriorityClass creation [OK]
Hint: Check if PriorityClass resource is applied when globalDefault fails [OK]
Common Mistakes:
  • Assuming pods need priorityClassName despite globalDefault
  • Setting globalDefault on PriorityClass with value 0
  • Believing globalDefault only applies to DaemonSets
5. You want to ensure that all pods without a specified PriorityClass get a default priority of 500, but also have a critical class with priority 2000. Which YAML snippet correctly sets this up?
hard
A. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: default-priority value: 500 globalDefault: true description: "Default priority" --- apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: critical value: 2000 globalDefault: false description: "Critical priority"
B. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: critical value: 2000 globalDefault: true description: "Critical priority" --- apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: default-priority value: 500 globalDefault: false description: "Default priority"
C. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: default-priority value: 500 globalDefault: false description: "Default priority" --- apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: critical value: 2000 globalDefault: true description: "Critical priority"
D. apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: default-priority value: 500 globalDefault: true description: "Default priority" --- apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: critical value: 2000 globalDefault: true description: "Critical priority"

Solution

  1. Step 1: Identify globalDefault usage

    Only one PriorityClass can have globalDefault: true. This sets the default priority for pods without a class.
  2. Step 2: Assign correct priorities

    Set the default-priority class with value 500 and globalDefault true. Set critical class with value 2000 and globalDefault false.
  3. Final Answer:

    Default priority 500 with globalDefault true, critical 2000 without globalDefault -> Option A
  4. Quick Check:

    Only one globalDefault PriorityClass allowed [OK]
Hint: Only one PriorityClass can have globalDefault true [OK]
Common Mistakes:
  • Setting globalDefault true on multiple PriorityClasses
  • Confusing which class should be default
  • Using same priority value for default and critical