11.Resolve Pod Deployment Issue

Published: (February 20, 2026 at 09:30 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Lab Information

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.

  • Pod name: webserver
  • Main container: nginx-container (image nginx:latest)
  • Sidecar container: sidecar-container (image ubuntu:latest)

The goal is to get the pod into a Running state and make the application accessible.

Note: The kubectl utility on jump_host is already configured to interact with the Kubernetes cluster.

Initial Inspection

kubectl get pods
kubectl describe pod webserver

If the pod is stuck, delete it before applying a corrected definition:

kubectl delete pod webserver

Create a Corrected Pod Definition

apiVersion: v1
kind: Pod
metadata:
  name: webserver
  labels:
    app: web-app
spec:
  containers:
  - name: nginx-container
    image: nginx:latest   # Fixed: removed extra 's'
    ports:
    - containerPort: 80
    volumeMounts:
    - name: shared-logs
      mountPath: /var/log/nginx
  - name: sidecar-container
    image: ubuntu:latest
    command:
      - sh
      - -c
    args:
      - while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done
    volumeMounts:
    - name: shared-logs
      mountPath: /var/log/nginx
  volumes:
  - name: shared-logs
    emptyDir: {}

Apply the manifest:

kubectl apply -f webserver-fixed.yaml

Verify the Deployment

kubectl get pods
kubectl describe pod webserver

Check logs for each container:

kubectl logs webserver -c nginx-container
kubectl logs webserver -c sidecar-container

Test the web server from inside the pod:

kubectl exec webserver -c nginx-container -- curl -s localhost:80 | head -n 5

If the output shows the expected HTML content, the pod is running correctly and the application is accessible.

Resources & Next Steps

Credits

  • All labs are from KodeKloud.
  • Thank you for providing these valuable resources.
0 views
Back to Blog

Related posts

Read more »

FullStack Diaries

!FT MJhttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2...