google-kubernetes-engine - 使用访问模式在 GKE 上创建 PV 卷的问题
问题描述
我有一个在 Google Cloud 上运行的 GKE 集群。我创建了一个持久性卷并安装了我的部署,因此我的应用程序和持久性之间的连接成功绑定。
我还使用以下链接在同一集群上运行 filebeat https://github.com/elastic/beats/blob/master/deploy/kubernetes/filebeat-kubernetes.yaml
应用程序和 filebeat 也都安装成功。PV 卷是使用访问模式创建的:使用 GCE 的ReadWriteOnce 。但是我的集群有许多节点正在运行,并且我的应用程序没有为所有正在运行的 pod 安装。在谷歌云 PV 卷不支持访问模式: ReadWriteMany。因此,由于应用程序未正确安装,我的 filebeat 也失败了,并且 filebeat 具有使用 deamonset 在许多节点上运行的能力。有没有办法解决上述问题。
解决方案
FileBeat 应该使用与卷稍有不同的卷。通常应用程序将日志记录到标准输出,然后容器运行时(例如 Docker 守护程序或 containerd)将日志保存在本地节点上。
FileBeat 需要在每个节点上运行,所以应该DaemonSet
按照你说的部署。但它也应该使用卷从节点挂载hostPath
卷。
请参阅您链接的这一部分DaemonSet
(此处未使用持久卷):
volumes:
- name: config
configMap:
defaultMode: 0640
name: filebeat-config
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log
# data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
- name: data
hostPath:
# When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/filebeat-data
type: DirectoryOrCreate
推荐阅读
- javascript - Angular - 如何最小化相同的代码使用?
- javascript - 无论大小如何调整我的画布大小以适应相同的内容
- python - 如何将当前url中的参数传递给Django 3中的html模板
- python - IndexError:列表索引超出范围(将地址转换为地理坐标的 Python 程序
- python-3.x - 使用 python 和 bs4 获取 url 中短语的计数
- linux - 有没有办法将命令的一部分与文本 bash 脚本结合起来
- java - Java中的设计模式和OOP原理
- webrtc - 在无法访问 Internet 的本地网络中使用 WebRTC 运行应用程序
- html - Flexbox 在 Chrome 中不工作,在 Firefox 中工作
- java - Android 应用程序在 EDF 文件解析时遇到 java.lang.OutOfMemoryError