Azure AKS - 如何在来自不同可用区的节点上运行的 pod 的公共(public)磁盘上安装卷?

标签 azure kubernetes logstash filebeat

我在不同可用区的 3 个节点上运行 AKS 群集(用于 HA)。它上面运行着一个 API,每个集群上都有 pod。

计划将 FileBeat 添加为 DaemonSet(每个节点上一个 pod),Logstash 从每个 FileBeat 实例收集日志。我选择 DaemonSet 而不是 SidecarProxy 模式,以消耗更少的节点资源。

为了让 FileBeat 能够从 API pod 读取日志,我想在托管 Azure 磁盘上安装一个卷,API 可以在该磁盘上写入日志文件,FileBeat 也可以从中读取日志文件。

Azure 磁盘当然只驻留在一个区域中。所以问题是,如果节点与磁盘不在同一可用区,则无法附加卷:

AttachVolume.Attach failed for volume "logging-persistent-volume" : Retriable: false, RetryAfter: 0s, HTTPStatusCode: 400, RawError: Retriable: false, RetryAfter: 0s, HTTPStatusCode: 400, RawError: { "error": { "code": "BadRequest", "message": "Disk /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/<resource group>/providers/Microsoft.Compute/disks/<disk name> cannot be attached to the VM because it is not in zone '3'." } }

我对 Kubernetes 和 Azure 还很陌生。那么,有没有办法在这种环境中为所有 API pod 提供共享卷呢?

感谢任何帮助! 谢谢!

最佳答案

回答您的问题:

您可以在其中添加一个管理 Azure 磁盘的存储解决方案,然后使用该存储解决方案创建卷。例如 Ceph,您可以使用 rook operator进行设置。

解决您的问题:

如果您让 API 记录到 stdout,kubernetes 会将这些日志文件写入磁盘中的特定位置。然后,Filebeat 可以从每个节点上的该位置读取数据,并将日志发送到您想要的任何位置。这是在 kubernetes 环境中记录日志的标准做法,除非您有将这些日志写入卷的特定需要,否则我不建议这样做。

根据filebeat docs :

You deploy Filebeat as a DaemonSet to ensure there’s a running instance on each node of the cluster.

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.

关于Azure AKS - 如何在来自不同可用区的节点上运行的 pod 的公共(public)磁盘上安装卷?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68919888/

相关文章:

azure - 如何在多个触发器上触发 Azure 逻辑应用程序?

azure - Powershell 获取所有 Azure 资源的每月消耗量

python - 如何将 scrapy 日志记录到 Logstash 中

elasticsearch - 从整数字段创建图表

azure - 通过 MSI token 获取访问权限时出现 Key Vault 403

Azure Web应用程序备份不起作用

kubernetes - docker 有镜像,但 kubernetes 说没有

node.js - 如何配置NGINX代理API调用以部署到Kubernetes上的后端?

kubernetes - 使用 NetworkPolicy 将 "kube-system"命名空间列入白名单

elasticsearch - Logstash 没有在 Elasticsearch 上创建索引