Skip to content
intermediate Phase 15 · CKA Certification Prep

CKA: Workloads & Scheduling

Prepare for CKA workloads and scheduling domain with hands-on practice.

1h
0 problems
Topic Progress 0%

Deploy, Scale, Roll Back

Deploy, Scale, Roll Back

Fast, declarative workflows for the exam:

kubectl create deploy web --image=nginx:1.25 --dry-run=client -o yaml > d.yaml
kubectl scale deploy web --replicas=4
kubectl set image deploy/web web=nginx:1.26
kubectl rollout status deploy/web
kubectl rollout history deploy/web
kubectl rollout undo deploy/web            # or --to-revision=N

Multi-container patterns: sidecars (logging, proxy), init containers (setup before the main container starts). CronJobs schedule batch work (schedule, concurrencyPolicy); StatefulSets give stable identity and ordered rollout for stateful services; DaemonSets ensure one pod per node — know which controller fits the requirement before writing YAML.

Scheduling Controls

Scheduling Controls

Pin, spread, and tolerate deliberately:

spec:
  nodeSelector: { disktype: ssd }
  tolerations:
  - { key: spot, operator: Exists, effect: NoSchedule }
  topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: topology.kubernetes.io/zone
    whenUnsatisfiable: ScheduleAnyway
    labelSelector:
      matchLabels: { app: web }

Taints repel (set with kubectl taint nodes n1 spot=true:NoSchedule); tolerations permit specific pods through; labels route with selectors (kubectl label node n1 disktype=ssd). Protect voluntary disruption:

minAvailable: 3   # or maxUnavailable: 1  → PDB

so kubectl drain waits instead of emptying the service. Understand Pending: read kubectl describe pod — taints, insufficient CPU/memory, affinity, or PVC binding are the usual causes.

Triage Order for Broken Workloads

Triage Order for Broken Workloads

Run the same sequence every time:

  1. Pending → kubectl describe pod events: unschedulable (taints/resources/affinity), volume problems
  2. ImagePullBackOff → image name/tag, registry auth, imagePullSecrets
  3. CrashLoopBackOff → kubectl logs <pod> --previous, then describe for exit codes (137 = OOM, 1 = app error)
  4. Running but not Ready → readiness probe path/port and app dependencies; check kubectl get endpoints
  5. Stuck Terminating → finalizers, hung preStop hooks, grace period (--force --grace-period=0 only as a last resort)

Also: kubectl get events --sort-by=.lastTimestamp for the freshest signals, and kubectl top pod once metrics exist. Interview framing: narrate which signal you read at each step and the specific fix it dictates — interviewers score the diagnostic order as heavily as the answer.

Quiz

1. A pod is stuck ImagePullBackOff. First thing to verify?

Question 1 options

2. What does a PDB actually control?

Question 2 options

3. kubectl rollout undo is used to…

Question 3 options

Flashcards

Question

Rollout trio

Answer

rollout status (watch), history (revisions), undo (--to-revision=N) — the Deployment rollback toolkit.

Question

Taint vs toleration

Answer

Taint on node repels pods; toleration on pod permits matching taints — both keyed by effect (NoSchedule/PreferNoSchedule/NoExecute).

Question

topologySpreadConstraints

Answer

Spreads replicas across topology keys (zone/host) with maxSkew, optionally soft via ScheduleAnyway.

Question

CrashLoopBackOff triage

Answer

kubectl logs --previous for output, describe for exit codes (137 OOM, 1 app error) and events.

Revision Notes

Key Takeaways

  • 1. Master create/scale/set-image/rollout commands before writing YAML by hand
  • 2. Scheduling = nodeSelector + tolerations + spread; PDBs protect drains
  • 3. Triage in fixed order: Pending → pull → crash → readiness → terminating

Interview Tips

  • • Give your triage checklist out loud with the command per step — structure impresses
  • • Explain when each scheduling primitive applies and how a PDB interacts with drain

Cheat Sheet

create --dry-run -o yaml; scale; set image; rollout status/history/undo. Schedule: nodeSelector, tolerations, topologySpread; PDB for drains. Triage: describe → pull → logs -p → readiness.

Continue Learning