kubectl logs retrieves the output captured from a Kubernetes container. Containerized applications commonly write messages to stdout and stderr rather than application-specific files; the container runtime captures these streams and stores them consistently, usually under /var/log/containers. Kubernetes therefore lets you inspect logs without accessing the hosting node or knowing the application’s file layout. section 5.3.2
View and stream a pod’s logs
Run `kubectl logs kiada` to print the container log. Add `-f` or `--follow` to stream new lines as requests arrive, and press Ctrl-C to stop. Add `--timestamps` to show the timestamp attached to each line. Limit output with `--since=2m`, `--since-time=2020-02-01T09:50:00Z`, or `--tail=10`. section 5.3.2
$ kubectl logs kiada Kiada - Kubernetes in Action Demo Application --------------------------------------------- Kiada 0.1 starting... Local hostname is kiada Listening on port 8080 Received request for / from ::ffff:10.244.2.1 #1 Received request for / from ::ffff:10.244.2.5 #2 Received request for / from ::ffff:127.0.0.1 #3
Use the sample output to recognize startup messages, listening status, and request lines returned by `kubectl logs`. section 5.3.2
The command can target a ReplicaSet instead of a specific pod. Use `kubectl logs rs/kiada -c kiada` when a pod has multiple containers. Add `--all-pods` to retrieve logs from every pod in the ReplicaSet, or `--all-containers` to include every container. Combining `--all-pods`, a container selection, and `-f` helps follow traffic distributed across replicas. section 14.1.2
Inspect logs across replicas
`kubectl logs rs/kiada --all-pods -c envoy` streams the Envoy container logs from all ReplicaSet pods. Use `kubectl logs rs/kiada --all-pods --all-containers` when every container’s output is needed. section 14.1.2


