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 thedefault namespace):
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:nginx plus three newpods-* Pods (four total).
Inspect a pod to find the image used
To inspect a Pod in detail use:Containers: section. Example excerpt:
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?
Thekubectl describe pod output shows the Node where the Pod is scheduled:
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:
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:
nginxandagentx. - The
agentxcontainer is in theWaitingstate with reasonErrImagePull— 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:
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.agentx does not exist in the registry, causing the image pull failure.
What does the READY column indicate?
TheREADY 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:
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:
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:
- Update the Pod image imperatively:
- Fix the YAML and reapply. Edit
redis.yamlto useredis(instead ofredis123):
redis pod should be in the Running state with 1/1 ready.
This completes the lab. Hit the End Lab button when finished.