All exams← All Certified Kubernetes Administrator (CKA) notes

Workloads & Scheduling: Certified Kubernetes Administrator (CKA) revision notes

Revision notes

## Workloads & Scheduling

Kubernetes Pods are the smallest deployable units, encapsulating one or more containers, storage resources, a unique network IP, and options that govern how the containers run. Multi-container Pods often use patterns like sidecar containers for logging or monitoring, and init containers for setup tasks that must complete before the main application containers start.

Pod Management Controllers

Deployments are the primary way to manage stateless applications. They define the desired state for a set of Pods and their underlying ReplicaSets. Deployments handle rolling updates and rollbacks, allowing zero-downtime updates and easy reversion to previous versions. ReplicaSets ensure a specified number of identical Pods are running at all times. DaemonSets ensure that all (or some) nodes run a copy of a specific Pod, useful for cluster-level services like logging agents or monitoring daemons.

Batch Workloads

For tasks that run to completion, Kubernetes provides Jobs. A Job creates one or more Pods and ensures that a specified number of them successfully terminate. CronJobs automate Jobs on a recurring schedule, similar to cron in Linux, enabling scheduled tasks like backups or report generation.

Scheduling and Resource Management

Kubernetes' scheduler places Pods on nodes based on various constraints. Resource Requests define the minimum CPU and memory a Pod needs, ensuring it gets scheduled on a node with sufficient capacity. Resource Limits define the maximum CPU and memory a Pod can consume, preventing resource exhaustion on a node.

Advanced scheduling includes Node Selectors for simple node assignment based on labels. Node Affinity provides more flexible rules (e.g., "prefer this node," "must run on this node"). Taints on nodes repel Pods unless those Pods have a matching Toleration. This is crucial for dedicating nodes or handling special hardware. Pod Disruption Budgets (PDBs) ensure that a minimum number of Pods for a given application remain running during voluntary disruptions (e.g., node maintenance), enhancing application availability. Liveness Probes detect if a container is running correctly and restart it if it fails. Readiness Probes determine if a container is ready to serve traffic, removing it from service endpoints if not. Startup Probes delay liveness and readiness checks until the application has started, preventing premature restarts for slow-starting apps.

Key facts

Flashcards

What is the primary purpose of a Kubernetes Pod?
To encapsulate one or more containers, storage, network IP, and options, forming the smallest deployable unit.
tap to reveal
How do you manage stateless applications with rolling updates and rollbacks in Kubernetes?
Using a **Deployment**.
tap to reveal
What Kubernetes object ensures that exactly one copy of a Pod runs on every (or selected) node?
A **DaemonSet**.
tap to reveal
Explain the difference between `requests` and `limits` for CPU/memory in a Pod.
**Requests** guarantee minimum resources for scheduling; **Limits** cap maximum consumption to prevent resource exhaustion.
tap to reveal
What is the function of a **Taint** on a node?
A Taint repels Pods from being scheduled on that node unless the Pod has a matching **Toleration**.
tap to reveal
What is the purpose of a **Liveness Probe**?
To detect if a container is running correctly and restart it if it fails, ensuring application health.
tap to reveal
How do you run a one-off task to completion in Kubernetes?
Using a **Job**.
tap to reveal
What does a **Pod Disruption Budget (PDB)** achieve?
It ensures that a minimum number of Pods for an application remain available during voluntary disruptions (e.g., node maintenance).
tap to reveal
Practice questions

Workloads & Scheduling: 5 practice questions

Q1. In a Deployment's rolling update strategy, what does the `maxSurge` parameter control?
  • A.  The total number of Pods allowed in the cluster during the update.
  • B.  The maximum number of new Pods that can be created above the desired number of replicas.
  • C.  The maximum number of old Pods that must be terminated before creating new ones.
  • D.  The maximum number of Pods that can be unavailable during the update.
Show answer & explanation
✓ Answer: B. The maximum number of new Pods that can be created above the desired number of replicas.
`maxSurge` specifies the maximum number of Pods that can be created over the desired `replicas` count, allowing for a smoother rollout without reducing capacity.
Q2. Which Kubernetes workload is specifically designed to ensure that a copy of a Pod runs on every node (or a specified subset of nodes) in the cluster?
  • A.  DaemonSet
  • B.  Deployment
  • C.  StatefulSet
  • D.  ReplicaSet
Show answer & explanation
✓ Answer: A. DaemonSet
A DaemonSet ensures that all (or some) nodes run a copy of a Pod, which is ideal for cluster-wide daemons like log collectors or monitoring agents.
Q3. A node is tainted with `key=gpu:NoSchedule`. Which of the following Pods will be eligible to be scheduled on this node?
  • A.  A Pod with a toleration for `key=gpu:NoExecute`.
  • B.  A Pod with a nodeSelector that matches the node's labels.
  • C.  A Pod with a toleration for `key=gpu:NoSchedule`.
  • D.  A Pod with no tolerations defined.
Show answer & explanation
✓ Answer: C. A Pod with a toleration for `key=gpu:NoSchedule`.
To be scheduled on a tainted node, a Pod must have a toleration that matches the node's taint. The key, value, and effect must be compatible.
Q4. What is a key characteristic of a StatefulSet that distinguishes it from a Deployment?
  • A.  It automatically creates a Service to expose its Pods.
  • B.  It is the only workload that can be scaled horizontally.
  • C.  Its Pods are completely interchangeable and have random names.
  • D.  It provides stable, unique network identifiers and persistent storage for each Pod.
Show answer & explanation
✓ Answer: D. It provides stable, unique network identifiers and persistent storage for each Pod.
StatefulSets are designed for stateful applications, providing each Pod with a stable, predictable hostname (e.g., web-0, web-1) and stable persistent storage.
Q5. You need to run a one-time batch processing task that runs to completion and then stops. Which Kubernetes object should you use?
  • A.  StatefulSet
  • B.  Job
  • C.  Deployment
  • D.  CronJob
Show answer & explanation
✓ Answer: B. Job
A Job is the ideal object for running a task that has a clear start and finish. It creates one or more Pods and ensures they complete successfully.
Test yourself
See the Certified Kubernetes Administrator (CKA) page

More Certified Kubernetes Administrator (CKA) topics