<p>How in kubernetes save pod logs from a period of time. I can render logs like kubectl logs POD_NAME, but how to save them to a file?</p>

Szelek
<p>In your application pod write logs to path in filesystem using a <code>volumeMounts</code>.</p>
<p>From the docs <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="nofollow noreferrer">here</a> use a sidecar container with a logging agent such as <a href="https://fluentbit.io" rel="nofollow noreferrer">fluentbit</a> to send logs written to the filesystem to a centralized logging backend such as splunk or Elasticsearch.</p>
<p><a href="https://i.stack.imgur.com/ufxsZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ufxsZ.png" alt="logging arch" /></a></p>
<pre><code>  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: fluentbit-logging-sidecar
  spec:
    selector:
      matchLabels:
        app: fluentbit-logging-sidecar
    replicas: 1
    template:
      metadata:
        labels:
          app: fluentbit-logging-sidecar
        volumes:
          - name: shared-data
            emptyDir: {}
          - name: config-volume
            configMap:
              name: fb-agent-config
        containers:
          - name: sample-logging
            image: &lt;image&gt;
            volumeMounts:
            - name: shared-data
              mountPath: /app/logs
          - name: fb-sidecar
            image: fluent/fluent-bit  
            volumeMounts:
            - name: shared-data
              mountPath: /app/logs
            - name: config-volume
              mountPath: /fluent-bit/etc/fluent-bit.conf
              subPath: fluent-bit.conf
</code></pre>
