Limit logs in kubernetes Limit logs in kubernetes kubernetes kubernetes

Limit logs in kubernetes


I'm assuming the container engine is docker in which case, you can configure docker to limit the logs written by your pod(s) container(s).

https://docs.docker.com/config/containers/logging/configure/


This is a Community Wiki answer so feel free to edit it and add any additional details you consider important.

As William has already answered this question, I'm only going to add a few details to make this more complete.

Please take a look at Logging Architecture in the official kubernetes docs. As you can read here "Kubernetes currently is not responsible for rotating logs, but rather a deployment tool should set up a solution to address that."

If your container runtime happens to be docker, you can set up your log rotation policy by editing/creating:

/etc/docker/daemon.json

(on Linux host)

or:

C:\ProgramData\docker\config\daemon.json

(on Windows host)

which may look as follows:

{  "log-driver": "json-file",  "log-opts": {    "max-size": "10m",    "max-file": "3",    "labels": "production_status",    "env": "os,customer"  }}