>_ IzzyLab

Hands-on task

This task is step 3 of the course “Kubernetes: first steps”

Pod description and logs

easy~7 min

There are two pods in the cluster; deal with each one:

  • pod shop-api just won't start. Find out which image it's trying to pull and write that image — name plus tag — to /root/image.txt;
  • pod billing is running and logs which database it connected to. Find out that database's name and write it to /root/db.txt.

Each file holds one line, just the answer.

What you'll practise:
  • kubernetes
  • kubectl describe
  • kubectl logs
  • events
  • ImagePullBackOff

Topic breakdown

When something's wrong with a pod, you look in two places.

Description — kubectl describe pod <name>. This is everything the cluster knows about the pod: image, container state, IP, node, and at the very end — the events (Events): "assigned to a node", "pulling image", "failed to pull image", "container started". If a pod won't start, the reason is almost always in the events.

Logs — kubectl logs <name>. This is everything the program in the container printed to the screen (stdout and stderr). Logs exist only if the container managed to start; if the image wasn't pulled, there are no logs — look at the description instead.

Example for pod web-1:

kubectl describe pod web-1          # description and events
kubectl logs web-1                  # the whole log
kubectl logs web-1 --tail=20        # last 20 lines
kubectl logs web-1 -f               # follow the log, exit with Ctrl+C

The ErrImagePull and ImagePullBackOff statuses mean the image couldn't be pulled: most often it's a typo in the image name or tag.

What's checked

  1. /root/image.txt contains the image shop-api is trying to pull
  2. /root/db.txt contains the database billing connected to

What it looks like