π© Step 1 β Create an NGINX Pod
Create a file named nginx-debug.yaml:
apiVersion: v1
kind: Pod
metadata:
name: nginx-debug
labels:
app: nginx-debug
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Apply it:
kubectl apply -f nginx-debug.yaml
π© Step 2 β Verify Pod Is Running
Check Pod status:
kubectl get pods -o wide
Expected output:
NAME READY STATUS RESTARTS AGE IP
nginx-debug 1/1 Running 0 5s 10.x.x.x
π© Step 3 β Wait Until Pod Is Ready (Recommended)
This avoids connection errors:
kubectl wait --for=condition=Ready pod/nginx-debug --timeout=60s
π© Step 4 β Exec Into the NGINX Container
Try bash first; if not available, fall back to sh:
kubectl exec -it nginx-debug -- /bin/bash 2>/dev/null || \
kubectl exec -it nginx-debug -- /bin/sh
Now you should be inside the container:
root@nginx-debug:/#
π© Step 5 β Perform Debugging Inside the Container
Below is a list of useful real-time debugging actions.
π 5.1 Check running processes
ps aux
You will see nginx master + worker processes.
π 5.2 Check NGINX config
cat /etc/nginx/nginx.conf
Or check site configs:
ls -R /etc/nginx
π 5.3 Test local NGINX web server
apt update 2>/dev/null || true
apt install curl -y 2>/dev/null || true
curl http://localhost
You should see the default NGINX welcome page HTML.
π 5.4 Check environment variables
env
π 5.5 Inspect container filesystem
ls -l /
ls -l /usr/share/nginx/html
π 5.6 Check network connectivity from inside the container
ping -c 3 google.com
Check internet DNS from the container:
nslookup google.com
π 5.7 View logs (inside container)
Check access and error logs:
ls -l /var/log/nginx
cat /var/log/nginx/access.log
cat /var/log/nginx/error.log
π 5.8 Inspect listening ports
netstat -tulnp
You should see:
tcp 0.0.0.0:80 β nginx
π© Step 6 β Exit the Container
exit
π© Step 7 β Clean Up (Optional)
kubectl delete pod nginx-debug
π Thanks for reading! If this post added value, a like β€οΈ, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
βοΈ AWS | GCP | βΈοΈ Kubernetes | π Security | β‘ Automation
π Sharing hands-on guides, best practices & real-world cloud solutions

Top comments (0)