0
0
Kubernetesdevops~30 mins

Debugging with kubectl debug in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Debugging with kubectl debug
📖 Scenario: You are a DevOps engineer responsible for maintaining a Kubernetes cluster. One of the pods running a web application is not responding correctly. You need to debug the pod to find out what is wrong without stopping the application.
🎯 Goal: Learn how to use kubectl debug to create a debugging container inside a running pod and inspect its environment.
📋 What You'll Learn
Use kubectl debug to create a debug container
Attach to the debug container's shell
Run commands inside the debug container to inspect the pod
Exit the debug session cleanly
💡 Why This Matters
🌍 Real World
Debugging live applications running in Kubernetes without stopping them helps keep services available and reduces downtime.
💼 Career
Knowing how to use <code>kubectl debug</code> is essential for DevOps engineers and site reliability engineers to troubleshoot issues quickly in production environments.
Progress0 / 4 steps
1
Identify the pod to debug
Use kubectl get pods to list all pods in the default namespace and find the pod named webapp-12345.
Kubernetes
Need a hint?

Use kubectl get pods to see all pods and their status.

2
Start a debug container inside the pod
Use kubectl debug with the --image=busybox option to start a debug container named debugger inside the pod webapp-12345.
Kubernetes
Need a hint?

Use kubectl debug webapp-12345 -it --image=busybox --share-processes --container=debugger to start an interactive debug container named 'debugger'.

3
Run commands inside the debug container
Inside the debug container shell, run ps to list running processes and cat /etc/hosts to check the hosts file.
Kubernetes
Need a hint?

Use ps to see processes and cat /etc/hosts to view the hosts file inside the debug container.

4
Exit the debug container
Type exit to leave the debug container shell and return to your local terminal.
Kubernetes
Need a hint?

Simply type exit to end the debug session.