CKA prep, by exam domain · Lesson 4 of 12 · about 55 minutes

Troubleshooting workloads and services

The other half of troubleshooting: apps that crash, can't pull their image, never get scheduled, or get no traffic. Five tickets on the practice cluster, solved with kubectl alone, then JSONPath and k top for the exam's 'write the answer to a file' tasks.

Exam domain: Troubleshooting · 30% of the exam

By the end you'll know

  • How to tell CrashLoopBackOff, ImagePullBackOff and Pending apart, and where to look for each
  • How to read a crashed container's last words, and mount a ConfigMap it can't find
  • How to read a FailedScheduling message as a tally of every node
  • Why a Service gets no traffic: an empty endpoint list or a wrong port
  • How to test a Service from inside the cluster, and the pipe that breaks --rm
  • How to pull exact answers out of kubectl with JSONPath, custom columns and sorting
  • How to install metrics-server, and find what uses the most CPU and memory

Before you start

  • You need: the cluster from Lesson 2, all nodes Ready.
  • Update the practice folder with git pull: it adds tickets 6 to 10 to break.sh.
  • The output below is from real runs on November 25, 2026, in New York, on an Apple silicon Mac. Times in the output are in UTC.

Lesson 3 broke the cluster. This one breaks apps, which is most of what the troubleshooting domain asks about. The good news: kubectl works the whole time, so there's no SSH and no crictl. Everything is get, describe, logs and editing objects.

Each ticket lives in its own namespace, t6 to t10, so every command needs -n. Forgetting it is the most common reason "the pod isn't there".

BASH
./break.sh 6          # break ticket 6 (running it again re-breaks it)
./break.sh undo 6     # for these tickets, undo deletes the namespace

Read the status first

The STATUS column of k get pods sorts most app failures into one of four groups before you read anything else:

StatusRestartsWhat happenedLook at
CrashLoopBackOffClimbingThe container started, then died, again and againk logs POD --previous
ImagePullBackOff / ErrImagePull0The container never started: no imageEvents in k describe pod
Pending, NODE is <none>0The scheduler found no node for itFailedScheduling in Events
Running, but no traffic0The pod is fine; the path to it isn'tThe Service: k describe svc

The restart count alone separates the first two: a crash needs a container that started, and a pull failure never gets that far.

Ticket 6: a crash loop

OUTPUT
Ticket 6: In namespace t6, the api Deployment never becomes ready. Find out why and fix it without deleting the Deployment.
BASH
k get pods -A -o wide
OUTPUT
NAMESPACE   NAME                   READY   STATUS             RESTARTS        AGE   IP              NODE
t6          api-7c89ddc9bd-bvqmt   0/1     CrashLoopBackOff   6 (4m36s ago)   10m   10.244.189.72   worker2

My first two describe attempts both failed:

OUTPUT
vagrant@cp1:~$ k describe pod api-7c89ddc9bd-bvqmt -o wide
error: unknown shorthand flag: 'o' in -o
vagrant@cp1:~$ k describe pod api-7c89ddc9bd-bvqmt
Error from server (NotFound): pods "api-7c89ddc9bd-bvqmt" not found
  • -o only works with get. describe has one output format.
  • NotFound for a pod you can see in get -A means a missing -n. kubectl looked in default.

With -n t6:

OUTPUT
    Command:
      sh
      -c
      echo loading config; cat /etc/app/config.yaml && sleep 3600
    State:          Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Wed, 25 Nov 2026 05:42:51 +0000
      Finished:     Wed, 25 Nov 2026 05:42:51 +0000
    Restart Count:  7
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-lcfx2 (ro)
...
  Warning  BackOff    42s (x15 over 11m)  kubelet  spec.containers{api}: Back-off restarting failed container api in pod ...

Exit Code: 1, with Started and Finished in the same second: the app fails the instant it starts. That's the app itself, not the node. I still checked both nodes' health with a JSONPath query (more on those later), and both were fine. The pod had been scheduled and started, so the node was never the problem.

The crashed container's own last words:

BASH
k logs -n t6 api-7c89ddc9bd-bvqmt --previous
  • --previous: the logs of the last container that crashed, not the new one waiting to start.
OUTPUT
loading config
cat: can't open '/etc/app/config.yaml': No such file or directory

The app expects a config file at /etc/app/config.yaml, and the pod's Mounts: showed nothing there. Does the config exist anywhere?

OUTPUT
vagrant@cp1:~$ k get cm -n t6
NAME               DATA   AGE
api-config         1      21m
kube-root-ca.crt   1      21m
vagrant@cp1:~$ k describe cm api-config -n t6
...
Data
====
config.yaml:
----
port: 8080
greeting: hello

It does, as a ConfigMap. It was just never mounted. The fix, with k edit deployment api -n t6, adds two pieces to the pod template:

YAML
        volumeMounts:            # under the container: WHERE
        - name: app-config
          mountPath: /etc/app
          readOnly: true
      volumes:                   # under the pod spec: WHAT
      - name: app-config
        configMap:
          name: api-config
  • volumes says what: a volume named app-config, filled from the ConfigMap api-config. It sits at the pod level.
  • volumeMounts says where: mount app-config at /etc/app. It sits under the container.
  • The name links them, and must match exactly.
  • Each key in the ConfigMap becomes a file. The key config.yaml became /etc/app/config.yaml, the exact path the app reads.
  • readOnly: true: the app reads its config and has no reason to change it.

On the exam, you won't type this from memory. In the Kubernetes docs, search "configure a pod to use a ConfigMap", copy the volume example, and change the names.

OUTPUT
vagrant@cp1:~$ k rollout status deployment/api -n t6
deployment "api" successfully rolled out
vagrant@cp1:~$ k logs deployment/api -n t6
loading config
port: 8080
greeting: hello
  • k rollout status: waits until the new pods are ready, and says whether the rollout worked.
  • k logs deployment/api: reads a pod of that Deployment without you having to look up its generated name.

Ticket 7: an image that doesn't exist

OUTPUT
Ticket 7: In namespace t7, the web Deployment's pods never start. Fix it.
OUTPUT
t7    web-76d64b8f88-b2h66    0/1   ImagePullBackOff   0   13h
t7    web-76d64b8f88-ngdbr    0/1   ImagePullBackOff   0   13h

0 restarts, so the container never started. The Events say why:

OUTPUT
  Warning  Failed   ...  Failed to pull image "nginx:1.27-alpien": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/nginx:1.27-alpien": failed to resolve image: docker.io/library/nginx:1.27-alpien: not found
  Warning  Failed   ...  Error: ErrImagePull
  Normal   BackOff  ...  Back-off pulling image "nginx:1.27-alpien"
  Warning  Failed   ...  Error: ImagePullBackOff

ErrImagePull is the failed attempt. ImagePullBackOff is the kubelet waiting longer and longer between attempts. The tag 1.27-alpien is a typo. The fix sets the image on the Deployment:

BASH
k set image deployment/web nginx=ginx:1.27-alpine -n t7
  • k set image deployment/NAME CONTAINER=IMAGE: the container's name goes before the =. k create deploy names the container after its image, so here it's nginx. k get deploy NAME -o wide shows it in the CONTAINERS column.

That fix had a typo of its own, ginx. It turned out to be useful, because the new pod failed with a different error:

OUTPUT
Failed to pull image "ginx:1.27-alpine": failed to pull and unpack image "docker.io/library/ginx:1.27-alpine": failed to resolve image: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
Error in EventsMeans
nginx:1.27-alpien: not foundThe repository exists, but that tag doesn't
pull access denied, repository does not exist or may require authorizationThe repository name is wrong, or it's private and needs credentials

Meanwhile, the Deployment showed a rollout stuck halfway:

OUTPUT
vagrant@cp1:~$ k get deployments -n t7
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
web    0/2     1            0           13h
vagrant@cp1:~$ k rollout status deployments/web -n t7
error: deployment "web" exceeded its progress deadline
  • The two old pods kept running beside the one new broken pod. A rollout doesn't remove old pods until new ones are ready. On a working app, that's what protects it from a bad update.
  • exceeded its progress deadline: the rollout made no progress for 10 minutes, the default. A new fix starts a fresh rollout.

Two small habits from this ticket: k describe rs web-76d64b8f88 -n t7 | grep 'Controlled By' confirmed the ReplicaSet belongs to Deployment/web, so that's what to fix, and k describe pod NAME -n t7 | sed -n '/Events:/,$p' printed only the Events, from that line to the end.

The real fix:

OUTPUT
vagrant@cp1:~$ k set image deployment/web nginx=nginx:1.27-alpine -n t7
deployment.apps/web image updated
vagrant@cp1:~$ k rollout status deployment/web -n t7 --timeout=120s
deployment "web" successfully rolled out
vagrant@cp1:~$ k get deployment web -n t7 -o wide
NAME   READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES              SELECTOR
web    2/2     2            2           14h   nginx        nginx:1.27-alpine   app=web
  • --timeout=120s: waits up to two minutes, then gives up instead of hanging.

Ticket 8: no room on any node

OUTPUT
Ticket 8: In namespace t8, the report Deployment's pod stays Pending. Fix it so it runs, without adding nodes.
BASH
k describe pod -n t8 -l app=report
  • -l app=report: describes pods by label, so you don't need the generated name.
OUTPUT
Node:             <none>
Status:           Pending
...
    Requests:
      cpu:        100m
      memory:     4Gi
...
  Warning  FailedScheduling  4m5s  default-scheduler  0/3 nodes are available: 1 node(s) had untolerated taint(s), 2 Insufficient memory. no new claims to deallocate, preemption: 0/3 nodes are available: 3 Preemption is not helpful for scheduling.

Read FailedScheduling as a tally of every node:

  • 0/3: none of the three nodes fit.
  • 1 node(s) had untolerated taint(s): cp1, with its control-plane taint.
  • 2 Insufficient memory: both workers. The pod asks for 4Gi, and each worker has about 1.8Gi allocatable (k describe node NAME, under Allocatable).
  • Preemption is not helpful: evicting lower-priority pods wouldn't free enough room either.

The scheduler counts requests, not real use. nginx needs a few megabytes, but the scheduler only knows what the pod asked for. The fix changes the request:

BASH
k set resources deployment/report -n t8 -c report --requests=cpu=100m,memory=128Mi
k rollout status deployment/report -n t8 --timeout=120s
k get pods -n t8 -l app=report -o wide
  • k set resources: changes requests (--requests=) or limits (--limits=) without opening an editor. -c report names the container.
OUTPUT
deployment "report" successfully rolled out
NAME                      READY   STATUS    RESTARTS   AGE   IP              NODE
report-6cd44dc65f-dbkcw   1/1     Running   0          10s   10.244.189.79   worker2

A FailedScheduling message also tells you something on its own: the scheduler is working. In Lesson 3's ticket 4, a Pending pod had no explanation at all, because the scheduler was down.

Ticket 9: a Service with no endpoints

OUTPUT
Ticket 9: In namespace t9, the shop Service gets no traffic, although its pods are Running. Fix the Service.

The pods were healthy, with the label app=shop. The Service:

OUTPUT
vagrant@cp1:~$ k describe sc shop -n t9
Error from server (NotFound): storageclasses.storage.k8s.io "shop" not found
vagrant@cp1:~$ k describe svc shop -n t9
Name:                     shop
Namespace:                t9
Selector:                 app=store
Type:                     ClusterIP
IP:                       10.111.181.162
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
Endpoints:
  • sc is a StorageClass. A Service is svc. The error message names the type it looked for.
  • An empty Endpoints line means the Service's selector matches no ready pod. The Service looks for app=store, and the pods are app=shop.
OUTPUT
vagrant@cp1:~$ k patch svc shop -n t9 --type=merge '{"spec":{"selector":{"app":"shop"}}}'
error: must specify --patch or --patch-file containing the contents of the patch
vagrant@cp1:~$ k patch svc shop -n t9 --type=merge -p '{"spec":{"selector":{"app":"shop"}}}'
service/shop patched
vagrant@cp1:~$ k describe svc shop -n t9 | grep Endpoints
Endpoints:                10.244.235.154:80,10.244.189.80:80
vagrant@cp1:~$ curl -I --max-time 5 http://10.111.181.162
HTTP/1.1 200 OK
Server: nginx/1.31.10
  • k patch ... -p '...': the change goes after -p (or --patch). --type=merge merges it into the object.
  • curl -I: shows only the response headers. --max-time 5 gives up after 5 seconds instead of hanging.
  • Every node can reach a Service's IP, which is why this works from cp1.

Ticket 10: the wrong port

OUTPUT
Ticket 10: In namespace t10, requests to the cart Service fail with connection refused. The pods are fine. Fix it.
OUTPUT
vagrant@cp1:~$ k describe svc cart -n t10
Selector:                 app=cart
IP:                       10.96.97.37
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
Endpoints:                10.244.235.155:8080,10.244.189.81:8080

This time the endpoints are there, so the selector is fine. But every endpoint is IP:8080. Take the Service out of the picture and ask a pod directly:

OUTPUT
vagrant@cp1:~$ curl -I --max-time 5 http://10.244.235.155:8080
curl: (7) Failed to connect to 10.244.235.155 port 8080 after 1 ms: Couldn't connect to server
vagrant@cp1:~$ curl -I --max-time 5 http://10.244.235.155:80
HTTP/1.1 200 OK
Server: nginx/1.31.10

nginx listens on 80, and the Service sends traffic to 8080. "Couldn't connect" right away means the pod is reachable, but nothing listens on that port. The fix, with k edit svc cart -n t10, is targetPort: 80:

OUTPUT
vagrant@cp1:~$ k describe svc cart -n t10 | grep Endpoints
Endpoints:                10.244.189.81:80,10.244.235.155:80
vagrant@cp1:~$ curl -I --max-time 5 http://10.96.97.37
HTTP/1.1 200 OK

Tickets 9 and 10 side by side:

EndpointsMeansFix
EmptyThe selector matches no ready podMake the selector match the pods' labels
Present, but IP:WRONG-PORTThe selector is fine, the target port isn'tSet targetPort to the port the container listens on

port is what clients call on the Service. targetPort is where the container listens. The endpoint list shows podIP:targetPort.

Test from inside the cluster

curl from a node proves the Service IP works. Apps call a Service by its name, from inside a pod, so test that way too:

BASH
k run tmp -n t10 --rm -it --image=busybox:1.37 --restart=Never -- wget -qO- http://cart
  • k run tmp: a temporary pod named tmp, in t10, so the short name cart resolves.
  • --rm: deletes the pod when the command ends. -it: attaches your terminal.
  • --restart=Never: a plain pod, not a Deployment.
  • wget -qO-: fetches the page and prints it. -q hides progress, -O- writes to the screen.

I piped mine into | head -4 to keep the output short, and it backfired:

OUTPUT
<!DOCTYPE html>
<html>
<head>
All commands and output from this session will be recorded in container logs, including credentials and sensitive information passed through the command prompt.
<title>Welcome to nginx!</title>

The page came back, so the Service works by name. But afterwards:

OUTPUT
t10    tmp    0/1    Completed    0    11s

The pod was still there. head closed the connection after four lines, which cut kubectl off before --rm could clean up. Don't pipe a k run --rm -it command; if you do, k delete pod tmp -n t10 cleans up.

The "recorded in container logs" line is kubectl's own warning for interactive sessions: what you type in an -it session can end up in the container's logs. Never type a secret into an interactive pod.

Exact answers: JSONPath, custom columns, sorting

A task may ask you to "write the answer to a file". kubectl can print exactly the field you need. Add > FILE to any of these, and check the file with cat afterwards.

OUTPUT
vagrant@cp1:~$ k get pods -n t10 -o jsonpath='{.items[*].metadata.name}'; echo
cart-854f9fcc59-4pgwp cart-854f9fcc59-jvmxj tmp
  • -o jsonpath='{...}': pulls exact fields from the object's JSON. .items[*] means every object in the list.
  • ; echo: adds a line break, because JSONPath output doesn't end with one.
  • That stray tmp is the pod --rm failed to delete.
OUTPUT
vagrant@cp1:~$ k get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}{end}'
cp1	192.168.34.154
worker1	192.168.34.155
worker2	192.168.34.156
  • {range .items[*]}...{end}: loops over every node. {"\t"} is a tab, {"\n"} a new line.
  • [?(@.type=="InternalIP")]: a filter that keeps only the address whose type is InternalIP.
OUTPUT
vagrant@cp1:~$ k get pods -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,NODE:.spec.nodeName | head -6
NS            NAME                                       NODE
default       web-558f679c7b-55jmr                       worker1
default       web-558f679c7b-67lcv                       worker1
default       web-558f679c7b-kvvcm                       worker1
default       web-558f679c7b-ng2dz                       worker1
default       web-558f679c7b-nq7b9                       worker1
  • -o custom-columns=HEADER:path,...: your own table. Simpler than JSONPath when you want columns.
OUTPUT
vagrant@cp1:~$ k get pods -A --sort-by=.metadata.creationTimestamp | tail -3
t10           cart-854f9fcc59-jvmxj                      1/1     Running     0               17m
t10           cart-854f9fcc59-4pgwp                      1/1     Running     0               17m
t10           tmp                                        0/1     Completed   0               11s
  • --sort-by=PATH: sorts by any field, oldest first for timestamps. tail -3 shows the newest three.

To find a field's path, run k get pod NAME -o yaml and follow the indentation: metadata: then name: is .metadata.name. k explain pod.spec describes every field.

What uses the most: k top

k top needs metrics-server, which collects CPU and memory use from every kubelet. A cluster someone else built may have it already. Yours doesn't yet:

BASH
k apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
k patch deploy metrics-server -n kube-system --type=json -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'
  • --type=json: a JSON patch, a list of exact operations. This one adds an argument to the end (/-) of the first container's args.
  • --kubelet-insecure-tls: don't verify the kubelets' certificates. A kubeadm cluster's kubelets serve with self-signed certificates, so metrics-server can't verify them.

Practice clusters only

--kubelet-insecure-tls turns off a security check. On a real cluster, give the kubelets properly signed serving certificates instead. Also, re-applying the upstream manifest after the patch undoes it: the manifest's args list replaces yours, and the flag silently disappears.

A minute later:

OUTPUT
vagrant@cp1:~$ k top nodes
NAME      CPU(cores)   CPU(%)   MEMORY(bytes)   MEMORY(%)
cp1       125m         6%       1020Mi          54%
worker1   46m          2%       872Mi           47%
worker2   55m          2%       849Mi           45%
vagrant@cp1:~$ k top pods -A --sort-by=memory | head -5
NAMESPACE     NAME                                       CPU(cores)   MEMORY(bytes)
kube-system   kube-apiserver-cp1                         41m          307Mi
kube-system   calico-node-m8qnn                          29m          96Mi
kube-system   calico-node-hkbbs                          18m          94Mi
kube-system   calico-node-d7kvt                          29m          94Mi
  • 125m: 125 millicores, an eighth of one CPU core.
  • --sort-by=memory (or cpu) puts the heaviest first. This is real use, unlike the requests the scheduler counts in ticket 8.

How the drills work

Each drill is a task to do from a blank terminal. Try it first, without looking. Then open "Show the fast way" to compare your commands, and read the notes under them: they cover the part people usually get wrong. Repeat a drill a few days later until you can do it cold, because the exam leaves little time to look things up.

Tickets 6 to 8 give you real failures for the first drill, and tickets 9 and 10 for the second. Run one again to re-break it.

The drills

A pod is in CrashLoopBackOff, ImagePullBackOff or Pending. Find the cause and fix it through its Deployment.

Show the fast way
BASH
k get pods -n NS                              # STATUS and RESTARTS first
k describe pod NAME -n NS | sed -n '/Events:/,$p'
k logs NAME -n NS --previous                  # CrashLoopBackOff: the crashed container's output
k set image deployment/NAME CONTAINER=IMAGE -n NS          # bad image
k set resources deployment/NAME -c CONTAINER --requests=memory=128Mi -n NS   # too big to schedule
k rollout status deployment/NAME -n NS --timeout=120s

Restarts climbing: the app crashes, so read logs --previous. 0 restarts and a pull error: read the Events, which say whether the tag or the repository is wrong. Pending with FailedScheduling: read it as a tally of every node. Always fix the Deployment, not the pod: the Deployment recreates a broken pod.

A Service gets no traffic, or connections to it are refused. Find out why and fix it.

Show the fast way
BASH
k describe svc NAME -n NS                     # Selector, TargetPort, Endpoints
k get pods -n NS --show-labels -o wide        # labels and pod IPs
curl -I --max-time 5 http://POD-IP:PORT       # ask a pod directly, from a node
k edit svc NAME -n NS                         # fix selector or targetPort
k describe svc NAME -n NS | grep Endpoints
k run tmp -n NS --rm -it --image=busybox:1.37 --restart=Never -- wget -qO- http://NAME

Empty Endpoints: the selector matches no ready pod, so compare it with the pods' labels. Endpoints present but connections refused: the targetPort is wrong, so curl the pod on each port to find the one it listens on. Don't pipe the k run --rm line, or the pod stays behind.

Write every node's name and InternalIP, one per line, to the file ~/nodes.txt. Then list all pods across namespaces, newest last.

Show the fast way
BASH
k get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}{end}' > ~/nodes.txt
cat ~/nodes.txt
k get pods -A --sort-by=.metadata.creationTimestamp

{range}...{end} loops, [?(@.type=="InternalIP")] filters a list by a field, and "\n" ends each line. Always cat the file: an empty or one-line file means the path or the loop is wrong. Find any field's path with -o yaml first.

Find the pod using the most memory in the whole cluster, and the busiest node.

Show the fast way
BASH
k top nodes
k top pods -A --sort-by=memory | head -3
k top pods -A --sort-by=cpu --containers | head -3

k top needs metrics-server. If it fails, check k get pods -n kube-system | grep metrics first. -A covers every namespace, and --containers splits each pod by container. If a task asks for the pod's name only, write the name, not the whole line.

On exam day

  • Put -n on every command, or set it once for the task with k config set-context --current --namespace=NS. Then put it back afterwards.
  • Fix the controller, not the pod. Deleting a broken pod just gets you another broken pod.
  • Verify the way the task describes success: pods Running and Ready, rollout status finished, a Service that returns a page.
  • Copy long YAML from the docs (volumes, probes, resources) and change the names. Typing it from memory costs time and invites typos.
  • "Write the answer to a file" means exactly that file. Write it, then cat it.

Clean up

The tickets each left a fixed app in its own namespace. Delete them all at once:

BASH
k delete ns t6 t7 t8 t9 t10
  • k delete ns: deletes each namespace and everything in it. It takes a few seconds per namespace.

Keep metrics-server: later lessons use k top.

In real life

  • CrashLoopBackOff from a missing config is a common production failure, usually after someone renames a ConfigMap or forgets to create it in a new environment.
  • Image tags get pinned by digest (nginx@sha256:...) in many companies, so a typo can't silently pull a different image.
  • Requests should be based on measured use. k top and longer-term monitoring show what an app really uses, and requests far above that waste nodes the way ticket 8 did.

Spot the problem

Work out what's wrong before you read the explanation.

"I deleted the crashing pod, and it came back." A teammate sees a pod in CrashLoopBackOff, deletes it, and a new one appears a few seconds later, crashing the same way. What happened? The pod belongs to a Deployment, which recreates it from the same broken template. Fix the Deployment (k edit deployment, k set image, k set resources), not the pod.

"The Service has endpoints, so the selector must be right, but nothing answers." Is the Service fine? Not necessarily: look at the port on each endpoint. If it's IP:8080 and the app listens on 80, the targetPort is wrong. Curl a pod IP on each port to see which one answers.

"My answer file is empty." Someone runs k get pods -o jsonpath='{.items[*].metadata.name}' > /opt/answer.txt for pods in namespace shop, and the file is empty. What's missing? -n shop. The command ran against default, which has no matching pods, and wrote nothing. Check every answer file with cat.

Keep this

ToUse
Read a crashed container's outputk logs POD -n NS --previous
Show only a pod's Eventsk describe pod POD -n NS | sed -n '/Events:/,$p'
Change a Deployment's imagek set image deployment/NAME CONTAINER=IMAGE -n NS
Change requests or limitsk set resources deployment/NAME -c CONTAINER --requests=memory=128Mi -n NS
Wait for a rolloutk rollout status deployment/NAME -n NS --timeout=120s
Patch one fieldk patch svc NAME -n NS --type=merge -p '{"spec":{...}}'
Check what a Service sends traffic tok describe svc NAME -n NS | grep Endpoints
Test a Service by namek run tmp -n NS --rm -it --image=busybox:1.37 --restart=Never -- wget -qO- http://NAME
Exact fields-o jsonpath='{.items[*].metadata.name}'
Your own columns-o custom-columns=NAME:.metadata.name,NODE:.spec.nodeName
Sort--sort-by=.metadata.creationTimestamp
Real CPU and memory usek top nodes, k top pods -A --sort-by=memory

Where you are now

You've fixed five broken apps with kubectl alone: a crash loop from a missing ConfigMap mount, an image that didn't exist, a pod too big for any node, a Service whose selector matched nothing, and a Service pointed at the wrong port. You can pull exact fields with JSONPath and see real resource use with k top. That's both halves of the troubleshooting domain, 30% of the exam. Lesson 5 turns to cluster maintenance: upgrading the cluster from v1.36 to the exam's v1.37, and backing up and restoring etcd.

Check yourself

  1. A pod in namespace shop shows CrashLoopBackOff, 7 restarts. k describe shows Exit Code 1, with Started and Finished in the same second. What's your next command?

  2. Two pods fail to pull their images. One says not found. The other says pull access denied, repository does not exist or may require authorization. Which is which?

  3. FailedScheduling says: 0/3 nodes are available: 1 node(s) had untolerated taint(s), 2 Insufficient memory. The task says not to change the nodes. What do you change?

  4. A Service's Endpoints line is empty. Its pods are Running and Ready. Which field do you compare with the pods' labels?

  5. A Service's endpoints are 10.244.1.5:8080 and 10.244.2.7:8080. Curling a pod on 8080 is refused, and on 80 returns 200 OK. What do you change?

  6. You run k run tmp --rm -it --image=busybox:1.37 --restart=Never -- wget -qO- http://web | head -3. Afterwards, k get pods still lists tmp as Completed. Why?

Key terms

  • CrashLoopBackOff: a container that keeps starting and dying, with the kubelet waiting longer between restarts.
  • ImagePullBackOff / ErrImagePull: the kubelet couldn't pull the image. ErrImagePull is a failed attempt, ImagePullBackOff the wait before the next.
  • FailedScheduling: an event from the scheduler, explaining why no node fits a pod.
  • Request: the CPU and memory a container asks for. The scheduler places pods by requests.
  • ConfigMap: an object that holds configuration as keys and values. Mounted as a volume, each key becomes a file.
  • Endpoints: the list of pod IPs and ports a Service sends traffic to, built from its selector.
  • targetPort: the port on the pod that a Service forwards traffic to.
  • JSONPath: a way to pick exact fields out of an object, used with -o jsonpath.
  • metrics-server: the add-on that collects CPU and memory use, so k top works.

Go deeper