Kubernetes Cheat Sheet: Logs Pods
Kubernetes Cheat Sheet: Logs Pods
Pods Logs
# Get all pods in the current namespace # Show logs (stdout) of a pod
kubectl get pods kubectl logs <pod>
# Get pods in all namespaces # Show logs (stdout) of pods that match a label
kubectl get pods --all-namespaces kubectl logs -l <label>=<value>
# Get pods with more details # Show logs of a previous instantiation of a container
kubectl get pods -o wide kubectl logs <pod> --previous
# Get the yaml for a pod # Show logs for a specific container in a pod (i.e. init
kubectl get pod <pod> -o yaml container)
kubectl logs <pod> -c <container>
# Inspect a pod
kubectl describe pods <pod> # Following logs from a pod
kubectl logs -f <pod>
# Get pods sorted by a metric
kubectl get pods \ # Follow all logs from a pod that match a label
--sort-by='.status.containerStatuses[0].restartCount' kubectl logs -f -l <label>=<value> --all-containers
# Get pods with their labels # Show logs with verbosity level of logs from 0 - 9
kubectl get pods --show-labels kubectl logs <pod> --v=<0:9>
# Get secrets with more details # Get deployments that match a label
kubectl get secrets -o wide kubectl get deployment -l <label>=<value>