Monitoring and Logging
Resource Monitoring
# Node resource usage
kubectl top nodes
# Pod resource usage
kubectl top pods
# Pod resource usage with containers
kubectl top pods --containers
Logging
# Get pod logs
kubectl logs <pod-name>
# Follow logs
kubectl logs -f <pod-name>
# Logs from previous container instance
kubectl logs <pod-name> --previous
# Logs from specific container in multi-container pod
kubectl logs <pod-name> -c <container-name>
Health Checks
Liveness Probe
Determines if a container is running.
Readiness Probe
Determines if a container is ready to accept traffic.
Startup Probe
Determines if a container application has started.
spec:
containers:
- name: app
image: nginx
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
startupProbe:
httpGet:
path: /startup
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 30
Next Steps
Learn about Troubleshooting to debug common issues.