Monday, 6 October 2025

Debugging Pods & Sidecars in Production

Our course you can check :-   Udemy course 



Ques:-

A junior DevOps team member encountered difficulties deploying a stack on the Kubernetes cluster. The pod fails to start, presenting errors. Let's troubleshoot and rectify the issue promptly.

There is a pod named webserver, and the container within it is named httpd-container, its utilizing the httpd:latest image.

Additionally, there's a sidecar container named sidecar-container using the ubuntu:latest image.

Identify and address the issue to ensure the pod is in the running state and the application is accessible.


Ans:-


raj@jumphost ~$ kubectl get pod

NAME        READY   STATUS             RESTARTS   AGE

webserver   1/2     ImagePullBackOff   0          6m36s


raj@jumphost ~$ kubectl logs webserver

Defaulted container "httpd-container" out of: httpd-container, sidecar-container

Error from server (BadRequest): container "httpd-container" in pod "webserver" is waiting to start: trying and failing to pull image


raj@jumphost ~$ kubectl describe pod webserver

Name:             webserver

Namespace:        default

Priority:         0

Service Account:  default

Node:             kodekloud-control-plane/172.17.0.2

Start Time:       Mon, 06 Oct 2025 09:52:57 +0000

Labels:           app=web-app

Annotations:      <none>

Status:           Pending

IP:               10.244.0.5

IPs:

  IP:  10.244.0.5

Containers:

  httpd-container:

    Container ID:   

    Image:          httpd:latests

    Image ID:       

    Port:           <none>

    Host Port:      <none>

    State:          Waiting

      Reason:       ImagePullBackOff

    Ready:          False

    Restart Count:  0

    Environment:    <none>

    Mounts:

      /var/log/httpd from shared-logs (rw)

      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7v7nm (ro)

  sidecar-container:

    Container ID:  containerd://c559916254f3ae3d5397b2c41350cfb8471db98945f2a9061cc3757a41bc7354

    Image:         ubuntu:latest

    Image ID:      docker.io/library/ubuntu@sha256:728785b59223d755e3e5c5af178fab1be7031f3522c5ccd7a0b32b80d8248123

    Port:          <none>

    Host Port:     <none>

    Command:

      sh

      -c

      while true; do cat /var/log/httpd/access.log /var/log/httpd/error.log; sleep 30; done

    State:          Running

      Started:      Mon, 06 Oct 2025 09:53:02 +0000

    Ready:          True

    Restart Count:  0

    Environment:    <none>

    Mounts:

      /var/log/httpd from shared-logs (rw)

      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7v7nm (ro)

Conditions:

  Type              Status

  Initialized       True 

  Ready             False 

  ContainersReady   False 

  PodScheduled      True 

Volumes:

  shared-logs:

    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)

    Medium:     

    SizeLimit:  <unset>

  kube-api-access-7v7nm:

    Type:                    Projected (a volume that contains injected data from multiple sources)

    TokenExpirationSeconds:  3607

    ConfigMapName:           kube-root-ca.crt

    ConfigMapOptional:       <nil>

    DownwardAPI:             true

QoS Class:                   BestEffort

Node-Selectors:              <none>

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  7m20s                   default-scheduler  Successfully assigned default/webserver to kodekloud-control-plane

  Normal   Pulling    7m19s                   kubelet            Pulling image "ubuntu:latest"

  Normal   Pulled     7m15s                   kubelet            Successfully pulled image "ubuntu:latest" in 3.742060201s (3.742079128s including waiting)

  Normal   Created    7m15s                   kubelet            Created container sidecar-container

  Normal   Started    7m15s                   kubelet            Started container sidecar-container

  Normal   Pulling    6m35s (x3 over 7m19s)   kubelet            Pulling image "httpd:latests"

  Warning  Failed     6m35s (x3 over 7m19s)   kubelet            Failed to pull image "httpd:latests": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/httpd:latests": failed to resolve reference "docker.io/library/httpd:latests": docker.io/library/httpd:latests: not found

  Warning  Failed     6m35s (x3 over 7m19s)   kubelet            Error: ErrImagePull

  Warning  Failed     5m59s (x6 over 7m15s)   kubelet            Error: ImagePullBackOff

  Normal   BackOff    2m13s (x21 over 7m15s)  kubelet            Back-off pulling image "httpd:latests"


raj@jumphost ~$ kubectl edit pod webserver

pod/webserver edited


raj@jumphost ~$ kubectl get pod

NAME        READY   STATUS    RESTARTS   AGE

webserver   2/2     Running   0          10m

raj@jumphost ~$ 

No comments:

Post a Comment