Skip to main content
In this lesson we walk through the solution for the Pods lab. This guide reinforces how to list, inspect, create, and troubleshoot Pods with kubectl. Follow the sequence below to match the lab tasks and expected outputs.

How many pods exist on the system?

List Pods in the current namespace (the lab uses the default namespace):
If there are no Pods in the namespace you will see:
Namespaces are out of scope for this lab. If you need to check another namespace in the future, use -n <namespace> (for example kubectl get pods -n kube-system).

Quick reference: common pod commands


Task: Create a pod running nginx

The simplest imperative way to create a Pod is:
You can check the exact syntax with:
Create the nginx Pod:
Expected output:
List Pods again to verify:
In this example there are four Pods: nginx plus three newpods-* Pods (four total).

Inspect a pod to find the image used

To inspect a Pod in detail use:
For example:
Look for the Containers: section. Example excerpt:
From this output you can see the container busybox uses the busybox image. Answer: the image used to create the newpods-* Pod shown above is busybox.

Which node is the pod placed on?

The kubectl describe pod output shows the Node where the Pod is scheduled:
You can also get node assignments in a more compact form with:
Example:
In the example above all new Pods were scheduled on the controlplane node.

How many containers are part of the pod webapp?

The READY column shown by kubectl get pods is ready-containers/total-containers. For more detail, run:
Example kubectl get pods output:
webapp shows 1/2 meaning 1 container ready out of 2 containers total. kubectl describe pod webapp will list both container entries (for example nginx and agentx).

What images are used in the webapp pod and what is the state of the agentx container?

From kubectl describe pod webapp you might see:
  • Images used: nginx and agentx.
  • The agentx container is in the Waiting state with reason ErrImagePull — it is not Running and not Ready.

Why is agentx in a Waiting/Error state?

Check the pod events in the kubectl describe pod output:
The error indicates Kubernetes failed to pull the image agentx from the registry (for example docker.io/library/agentx). The image agentx does not exist on the registry (Docker Hub or your configured registry), so the pull fails.
Image pull failures (e.g., ErrImagePull or ImagePullBackOff) typically mean the image name is wrong, the image does not exist in the registry, or there are registry authentication/network issues.
Correct answer: a Docker image named agentx does not exist in the registry, causing the image pull failure.

What does the READY column indicate?

The READY column (for example 1/2) shows the number of containers in the Pod that are Ready over the total number of containers in the Pod. A container is considered Ready when its readiness probe (if configured) indicates readiness; otherwise it is typically considered Ready once the container is running and available to serve traffic. So 1/2 means 1 container is ready out of 2 containers in that Pod.

Delete the webapp pod

Delete the Pod:
Expected output:

Create a new pod named redis with a wrong image name (redis123) using a pod YAML

You can generate a Pod YAML using kubectl run with --dry-run=client -o yaml. Note: the older --dry-run without a value is deprecated — use --dry-run=client. Generate YAML to stdout:
Example YAML output:
Save to a file:
Create the pod from the YAML:
Expected:
Because the image name redis123 is invalid (it doesn’t exist), the Pod will show an image pull error:

Fix the redis pod image to redis and get it running

You have several options to fix the image:
  1. Update the Pod image imperatively:
This updates the container image on the single Pod.
  1. Fix the YAML and reapply. Edit redis.yaml to use redis (instead of redis123):
redis.yaml (updated):
Apply the change:
Or replace the Pod (delete & recreate):
After fixing the image, verify the Pod status:
Now the redis pod should be in the Running state with 1/1 ready.
This completes the lab. Hit the End Lab button when finished.

Watch Video