Logging
Test Environments
Before deploying to production, always verify the application in different environments:
- Test in local environment
- Test in test/dev environment
- Finally in production environment
Debugging Your Kubernetes Cluster
Mistakes and bugs can happen — be prepared to investigate and resolve them efficiently.
Troubleshooting Pods
List pods and their status:
Viewing Pod Logs and Events
Level 1: View Full Pod Definition
Level 2: Describe the pod (Look at Events for errors)
Level 3: View Pod logs (commands/process outputs)
Scenario Example: Debugging a Broken Image
Suppose you find the following error in the logs:
The issue is a misspelled image name (nginax instead of nginx). To fix it:
Step 1: Delete the Pod
Step 2: Edit the Pod
# pod2.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx12
spec:
containers:
- name:
image: nginx:1.15.0 # <-- Corrected image name
ports:
- containerPort: 80
Step 3: Apply the Updated Pod
Step 4: Verify the Pod is Running
You should see: