<p>I want to ship my application logs from my K8s pods to hosted ELK. I want to used a PVC. This <a href="https://docs.digitalocean.com/products/kubernetes/how-to/add-volumes/" rel="nofollow noreferrer">Link</a> mentions that the pod should be owned by a StatefulSet. Is this a general recommendation or specific to DigitalOcean?</p>

zilcuanu
<p>This is a general recommendation. The reason is, you will have to ensure that your logging pods should be ready <em>before</em> the application pods can start. Additionally, say you had a <code>Pod</code> named <code>logging-pod-1</code> sending logs of application pod <code>app-pod-1</code> to <code>elk</code>, and the <code>logging-pod-1</code> crashes for some reason, using a <code>StatefulSet</code> ensure that the new pod started <em>assumes the identity of <code>logging-pod-1</code></em>, and this way the &quot;state&quot; of the operation can be maintained across failures/rescheduling/restarts, ensuring that no logs are missed and logging isn't affected.</p>
<p>This part of &quot;assuming the identity&quot; can mean something like, when the new pod comes up, k8s will know which PVC to attach to this pod. This will be the same PVC that the crashed pod was using, and therefore the new pod will simply &quot;take over the task&quot; by mounting the same PV and starting on its work.</p>
<p>This is a very common design pattern and since you need to ensure ordering, a <code>StatefulSet</code> is a natural choice for deploying this logging functionality. You can learn more about <code>StatefulSets</code> <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">here</a> in the docs.</p>
