0
0
Kubernetesdevops~10 mins

Viewing Pod details and logs in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Viewing Pod details and logs
Start: Identify Pod
kubectl get pods
Select Pod Name
kubectl describe pod
View Pod Details
End: Analyze Output
First, list pods to find the pod name. Then use 'kubectl describe pod' to see details or 'kubectl logs pod' to see logs.
Execution Sample
Kubernetes
kubectl get pods
kubectl describe pod my-pod
kubectl logs my-pod
List pods, then show details and logs of a specific pod named 'my-pod'.
Process Table
StepCommandActionOutput Summary
1kubectl get podsList all pods in current namespaceDisplays pod names, statuses, and age
2kubectl describe pod my-podShow detailed info about 'my-pod'Shows pod metadata, status, containers, events
3kubectl logs my-podShow logs from 'my-pod' containersOutputs container logs line by line
4-End of commandsNo further output
💡 All commands executed; pod details and logs displayed for analysis.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3
pod_listempty['my-pod', 'other-pod']unchangedunchanged
selected_podnonenone'my-pod''my-pod'
pod_detailsnonenonemetadata + status + eventsunchanged
pod_logsnonenonenonelog lines from container
Key Moments - 2 Insights
Why do we run 'kubectl get pods' before describing or viewing logs?
Because 'kubectl get pods' shows the pod names available, so you know which pod to describe or get logs from, as seen in execution_table step 1.
What is the difference between 'kubectl describe pod' and 'kubectl logs'?
'kubectl describe pod' shows detailed pod info like status and events, while 'kubectl logs' shows the actual output from the pod's containers, as shown in steps 2 and 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what command lists all pods?
Akubectl get pods
Bkubectl describe pod my-pod
Ckubectl logs my-pod
Dkubectl delete pod my-pod
💡 Hint
Check Step 1 in the execution_table for the command that lists pods.
At which step do we see the pod's events and status details?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Refer to Step 2 in execution_table where 'kubectl describe pod' is run.
If you want to see what your pod is printing out, which command would you use?
Akubectl get pods
Bkubectl describe pod my-pod
Ckubectl logs my-pod
Dkubectl exec my-pod
💡 Hint
Look at Step 3 in execution_table for the command that shows pod logs.
Concept Snapshot
kubectl get pods  # List pods in namespace
kubectl describe pod <pod-name>  # Show detailed pod info
kubectl logs <pod-name>  # Show container logs
Use get pods first to find pod names
Describe shows status and events
Logs show what the pod outputs
Full Transcript
To view pod details and logs, first run 'kubectl get pods' to list all pods and find the pod name. Then use 'kubectl describe pod <pod-name>' to see detailed information like status, containers, and events. To see what the pod is printing, run 'kubectl logs <pod-name>'. This sequence helps you understand pod state and troubleshoot by checking logs.