<p>I'm running an AKS cluster on 3 nodes in different availability zones (for HA). There's an API running on it with pods on each cluster.</p>
<p>The plan is to add FileBeat as a DaemonSet (one pod on each node), and Logstash collecting the logs from each FileBeat instance. I chose DaemonSet over SidecarProxy pattern to consume less ressources on the node.</p>
<p>For FileBeat being able to read the logs from the API pods, I wanted to mount a volume on a managed azure disk on which the APIs can write their log files and from which FileBeat can read them.</p>
<p>The Azure Disk is of course only residing in one zone. So the problem is that the volume can't be attached if the node is not in the same AZ than the disk:</p>
<pre><code>AttachVolume.Attach failed for volume &quot;logging-persistent-volume&quot; : Retriable: false, RetryAfter: 0s, HTTPStatusCode: 400, RawError: Retriable: false, RetryAfter: 0s, HTTPStatusCode: 400, RawError: { &quot;error&quot;: { &quot;code&quot;: &quot;BadRequest&quot;, &quot;message&quot;: &quot;Disk /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/&lt;resource group&gt;/providers/Microsoft.Compute/disks/&lt;disk name&gt; cannot be attached to the VM because it is not in zone '3'.&quot; } }
</code></pre>
<p>I'm quite new to Kubernetes and Azure. So, is there a way to have a shared volume for all API pods in this kind of environment?</p>
<p>Any help is appreciated!
Thanks!</p>

<p><strong>To answer your question</strong>:</p>
<p>You can add a storage solution in between which manages Azure Disks, and then create your volumes using that storage solution instead. An example would be <code>Ceph</code>, and you can use <a href="https://rook.io" rel="nofollow noreferrer">rook operator</a> to set that up.</p>
<p><strong>To solve your problem</strong>:</p>
<p>If you let your API log to stdout, kubernetes will write those log files in a disk at a specific location. Filebeat can then read from this location on each node and send your logs wherever you want them to be. This is the standard practice used for logging in the kubernetes environment, unless you have a specific need to write those logs to a volume, I wouldn't recommend that.</p>
<p>According to the <a href="https://www.elastic.co/guide/en/beats/filebeat/current/running-on-kubernetes.html" rel="nofollow noreferrer">filebeat docs</a>:</p>
<blockquote>
<p>You deploy Filebeat as a DaemonSet to ensure there’s a running instance on each node of the cluster.</p>
<p>The Docker logs host folder (/var/lib/docker/containers) is mounted on
the Filebeat container. Filebeat starts an input for the files and
begins harvesting them as soon as they appear in the folder.</p>
</blockquote>
