Profile picture
Sidharth R
  • Home
  • Posts
  • Journal
  • Home
  • Posts
  • Journal
  • Search
  1. Home
  2. Labs - Learn by Doing
  3. Kubernetes labs
  4. Pods in Kubernetes

Pods in Kubernetes

Updated: 05 May 2026 ⚬ Page views: loading...

Task

The lab consists of a k8s master node & worker node. You have access to a terminal on the controlplane.

Task 1

How many pods exist on the system?

I ran :

list pods
$ k get po
No resources found in default namespace.

Ans: 0

Task 2

Create a new pod using the nginx image.

Ans:

$ kubectl run nginx --image=nginx
pod/nginx created

The basic syntax is:

kubectl run <pod-name> --image=<image-name>

Note By default, the image will be pulled from Docker Hub.

Task 3

How many pods are created now?

$ k get po
NAME            READY   STATUS    RESTARTS   AGE
newpods-4gm4b   1/1     Running   0          6m23s
newpods-64wtz   1/1     Running   0          6m23s
newpods-vqvkt   1/1     Running   0          6m23s
nginx           1/1     Running   0          2m51s

Ans: 4

Task 4

Which image is specified for the pods whose names begin with the newpods- prefix?

$ k describe pod newpods-4gm4b 
Name:             newpods-4gm4b
Namespace:        default
Priority:         0
Service Account:  default
Node:             controlplane/10.244.213.49
Start Time:       Tue, 05 May 2026 16:51:01 +0000
Labels:           tier=busybox
Annotations:      
Status:           Running
IP:               10.22.0.11
IPs:
  IP:           10.22.0.11
Controlled By:  ReplicaSet/newpods
Containers:
  busybox:
    Container ID:  containerd://96575f118eedf40bcf786e56959afc8bea02a63483ee37389c14caee7a959816
    Image:         busybox
    Image ID:      docker.io/library/busybox@sha256:1487d0af5f52b4ba31c7e465126ee2123fe3f2305d638e7827681e7cf6c83d5e
    Port:          
    Host Port:     

Ans: busybox

Taks 5

Which nodes are these pods placed on?

$ k describe pod newpods-4gm4b 
Name:             newpods-4gm4b
Namespace:        default
Priority:         0
Service Account:  default
Node:             controlplane/10.244.213.49
Labels:           tier=busybox

Ans: controlplane

Task 6

We just created a new pod named webapp. How many containers are part of the webapp pod?

$ k describe pod webapp 
Name:             webapp
Namespace:        default
Priority:         0
Service Account:  default
Node:             controlplane/10.244.213.49
Start Time:       Tue, 05 May 2026 17:02:39 +0000
Labels:           
Annotations:      
Status:           Pending
IP:               10.22.0.13
IPs:
  IP:  10.22.0.13
Containers:
  nginx:
    Container ID:   containerd://300659a4ba347fe8106b7b3694ed709a0ac18b45e4fc75168a6adc2e32cbcee4
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:6e23479198b998e5e25921dff8455837c7636a67111a04a635cf1bb363d199dc
    Port:           
    Host Port:      
    State:          Running
      Started:      Tue, 05 May 2026 17:02:40 +0000
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-j2jfj (ro)
  agentx:
    Container ID:   
    Image:          agentx
    Image ID:       
    Port:           
    Host Port:      
    State:          Waiting
      Reason:       ErrImagePull
    Ready:          False
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-j2jfj (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       False 
  ContainersReady             False 
  PodScheduled                True 
Volumes:
  kube-api-access-j2jfj:
    Type:                  

Ans: 2

Task 7

What images are used in the new webapp pod?

Ans: nginx & agentx

Task 8

What is the state of the container agentx in the pod webapp?

$k describe po webapp 
Name:             webapp
Namespace:        default
Priority:         0
Service Account:  default
Node:             controlplane/10.244.154.36
Start Time:       Tue, 05 May 2026 17:16:32 +0000
Labels:           
Annotations:      
Status:           Pending
IP:               10.22.0.13
IPs:
  IP:  10.22.0.13
Containers:
  nginx:
    Container ID:   containerd://4219ce391ae60ab9b4f5615b8f063ffa67e8f38e14a524bc37ebdc89eb78a91d
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:6e23479198b998e5e25921dff8455837c7636a67111a04a635cf1bb363d199dc
    Port:           
    Host Port:      
    State:          Running
      Started:      Tue, 05 May 2026 17:16:33 +0000
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-nprft (ro)
  agentx:
    Container ID:   
    Image:          agentx
    Image ID:       
    Port:           
    Host Port:      
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-nprft (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       False 
  ContainersReady             False 
  PodScheduled                True 
Volumes:
  kube-api-access-nprft:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    Optional:                false
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age                 From               Message
  ----     ------     ----                ----               -------
  Normal   Scheduled  2m6s                default-scheduler  Successfully assigned default/webapp to controlplane
  Normal   Pulling    2m5s                kubelet            spec.containers{nginx}: Pulling image "nginx"
  Normal   Pulled     2m5s                kubelet            spec.containers{nginx}: Successfully pulled image "nginx" in 352ms (352ms including waiting). Image size: 62964342 bytes.
  Normal   Created    2m5s                kubelet            spec.containers{nginx}: Container created
  Normal   Started    2m5s                kubelet            spec.containers{nginx}: Container started
  Normal   Pulling    36s (x4 over 2m5s)  kubelet            spec.containers{agentx}: Pulling image "agentx"
  Warning  Failed     35s (x4 over 2m4s)  kubelet            spec.containers{agentx}: Failed to pull image "agentx": failed to pull and unpack image "docker.io/library/agentx:latest": failed to resolve reference "docker.io/library/agentx:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
  Warning  Failed     35s (x4 over 2m4s)  kubelet            spec.containers{agentx}: Error: ErrImagePull
  Normal   BackOff    9s (x7 over 2m3s)   kubelet            spec.containers{agentx}: Back-off pulling image "agentx"
  Warning  Failed     9s (x7 over 2m3s)   kubelet            spec.containers{agentx}: Error: ImagePullBackOff

Ans: Error

Task 9

Why do you think the container agentx in pod webapp is in error?

Ans: the image can’t be pulled

Task 10

What does the READY column in the output of the kubectl get pods command indicate?

Ans: Ready containers in pod / Total containers in pod.

Task 11

Delete the webapp Pod.

$ k delete po webapp 
pod "webapp" deleted from default namespace

Task 12

Create a new pod with the name redis and the image redis123.

Utilize a pod-definition YAML file. Please note that the image name redis123 is intentionally incorrect. Do NOT correct the image at this stage; you will address this in the subsequent task.

Solution:

Create a manifest file using dry run:

k run redis --image=redis123 --dry-run=client -o yaml > redis.yaml

This resulted in:

redis.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: redis
  name: redis
spec:
  containers:
  - image: redis123
    name: redis
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

Now to create resource from this manifest file, run:

$ k create -f redis.yaml 
pod/redis created

Verify it’s running:

$ k get po
NAME            READY   STATUS         RESTARTS      AGE
newpods-74h58   1/1     Running        1 (97s ago)   18m
newpods-8z2bk   1/1     Running        1 (96s ago)   18m
newpods-jkzvs   1/1     Running        1 (97s ago)   18m
nginx           1/1     Running        0             17m
redis           0/1     ErrImagePull   0             43s

Task 13

Change the image on this pod to redis.

Ans:

The updated manifest file:

redis.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: redis
  name: redis
spec:
  containers:
  - image: redis
    name: redis
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

Then run k apply -f redis.yaml to update the pod.

Confirm:

$ k get po
NAME            READY   STATUS    RESTARTS        AGE
newpods-74h58   1/1     Running   1 (7m12s ago)   23m
newpods-8z2bk   1/1     Running   1 (7m11s ago)   23m
newpods-jkzvs   1/1     Running   1 (7m12s ago)   23m
nginx           1/1     Running   0               23m
redis           1/1     Running   0               6m18s

Nerdsid.com

Links
  • Home
  • Contact
  • About
  • Posts
  • Journal
  • Quotes
  • Links worth your time
  • Notes
  • Style guide
© 2026 Sidharth R.
All content on this website is licensed under CC BY-NC-SA 4.0.