Log Management in Kubernetes
Throughout this book, after running an exercise, we will often ask you to view the logs of a container by running a command such as:
kubectl logs mypod -n myns
This allows us to view logs, but what’s happening to get the logs? Where are the logs stored and how are they managed? What are the processes to manage archiving logs? It turns out this is a complex topic that often gets overlooked when getting started with Kubernetes. The rest of this chapter will be dedicated to answering these questions. First, let’s discuss how Kubernetes stores logs, and then we’ll get into pulling those logs into a centralized system.
Understanding Container Logs
Before we ran containers, logging was relatively straightforward. Your application usually had a library that was responsible for sending data to logs. That library would rotate the logs and often clean out old logs. It wasn’t unusual to have multiple logs for multiple...