<p>I have generated logs for my pods using <code>kubectl logs 'pod name</code>. But I want to persist these logs in a volume (some kind of persistent storage), because container logs will get wiped out if the pods go down. Is there a way to do this? Do I have to write some sort of a script?
I have read many answers but I still do  not understand how to go about it, any help is appreciated. Thanks!</p>

<p>Under <code>Logging Architecture</code> Kubernetes <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="noreferrer">documents</a> goes thru couple of way to set up loggin in your cluster.</p>
<p>The most interesting for you might be <code>Cluster-level logging architecture</code>:</p>
<blockquote>
<p>While Kubernetes does not provide a native solution for cluster-level
logging, there are several common approaches you can consider. Here
are some options:</p>
<ul>
<li>Use a node-level logging agent that runs on every node.</li>
<li>Include a dedicated sidecar container for logging in an application pod.</li>
<li>Push logs directly to a backend from within an application</li>
</ul>
</blockquote>
<p>There are many solutions for collecting pod logs and shipping them to a centralized location such as:</p>
<ul>
<li><a href="https://www.fluentd.org/" rel="noreferrer">fluentd</a></li>
<li><a href="https://www.splunk.com/" rel="noreferrer">splunk</a></li>
<li><a href="https://www.elastic.co/home" rel="noreferrer">elastic</a></li>
</ul>
<p>Keeping logs outside of cluster has benefits. If you cluster begins to have issues its more likely that your inside logging architecure will also face them.</p>
