Typorithm · medium

kubectl logs & exec

kubectl-logs-execkubernetesdebuglogsexec
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn kubectl logs & exec

0%

kubectl Commands

Debug a pod with describe (events), logs -f (live output), logs --previous (after a crash), and exec -it (a shell inside).

When a pod misbehaves, describe is the first stop: it surfaces events like image pull or scheduling failures.

logs streams container output; -f follows it live and --previous recovers the crashed instance's logs.

exec -it drops you into a shell inside the container to inspect files, env, and connectivity.

01

describe shows events first.

02

logs -f follows; --previous after a crash.

03

exec -it -- sh opens a shell.

kubectl describe pod web-0
kubectl logs web-0 -f
kubectl logs web-0 --previous
kubectl exec -it web-0 -- sh

Read the implementation

Connect each part of the code to the concept before you type.

1. Events & state

describe shows a resource's spec, status, and recent events — the first debugging stop.

kubectl describe pod web-0

2. Follow logs

-f streams the container's stdout/stderr live.

kubectl logs web-0 -f

3. Crashed container

--previous shows logs from the prior, crashed container instance.

kubectl logs web-0 --previous

4. Shell inside

exec -it opens an interactive shell in the running container.

kubectl exec -it web-0 -- sh

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

kubectl logs & exec: Lesson & Practice · Typorithm | ApplyDjinn