<p>I use the sidecar method of k8s to collect logs. If I use emptydiry to mount, will the uncollected logs be lost when the pod is moved to another node?</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
 name: counter
spec:
 containers:
   - name: count
     image: busybox
     ...    
     volumeMounts:
       - name: varlog
         mountPath: /var/log
   - name: count-agent
     image: k8s.gcr.io/fluentd-gcp:1.30
     ...
     volumeMounts:
       - name: varlog
         mountPath: /var/log
       - name: config-volume
         mountPath: /etc/fluentd-config
 volumes:
   - name: varlog
     emptyDir: {}
   - name: config-volume
     configMap:
       name: fluentd-config

</code></pre>

zzw
<p>Yes, you will lose the data. <code>emptyDir</code> is erased when a pod is removed (e.g. when it is evicted to another node).</p>
<p>The logs that you'd like to preserve should be printed to <code>stdout</code>; then collected and persisted by your logging subsystem in the cluster.</p>
<p>From the <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer">docs</a>:</p>
<blockquote>
<p>An <code>emptyDir</code> volume is first created when a Pod is assigned to a node, and exists as long as that Pod is running on that node.</p>
</blockquote>
