<p>How can one define log retention for kubernetes pods?
For now it seems like the log file size is not limited, and it is uses the host machine complete resources.</p>

Yevgeni Reif
<p>According to <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="noreferrer">Logging Architecture</a> from kubernetes.io there are some options</p>

<p><strong>First option</strong></p>

<blockquote>
  <p>Kubernetes currently is not responsible for rotating logs, but rather
  a deployment tool should set up a solution to address that. For
  example, in Kubernetes clusters, deployed by the kube-up.sh script,
  there is a <a href="https://linux.die.net/man/8/logrotate" rel="noreferrer">logrotate</a> tool configured to run each hour. You can also
  set up a container runtime to rotate application’s logs automatically,
  e.g. by using Docker’s log-opt. In the kube-up.sh script, the latter
  approach is used for COS image on GCP, and the former approach is used
  in any other environment. In both cases, by default rotation is
  configured to take place when log file exceeds 10MB.</p>
</blockquote>

<p>Also</p>

<p><strong>Second option</strong></p>

<blockquote>
  <p>Sidecar containers can also be used to rotate log files that cannot be rotated by the application itself. <a href="https://github.com/samsung-cnct/logrotate" rel="noreferrer">An example</a> of this approach is a small container running logrotate periodically. However, it’s recommended to use stdout and stderr directly and leave rotation and retention policies to the kubelet.</p>
</blockquote>

<p><a href="https://i.stack.imgur.com/lIp0E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lIp0E.png" alt="enter image description here"></a></p>
