首页 > 解决方案 > 使用访问模式在 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 在许多节点上运行的能力。有没有办法解决上述问题。

标签: google-kubernetes-enginefilebeatpersistent-volumes

解决方案


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

推荐阅读