如何在 GKE 中使用 ReadWriteMany 创建持久卷声明? [英] How do I create a persistent volume claim with ReadWriteMany in GKE?

查看:37
本文介绍了如何在 GKE 中使用 ReadWriteMany 创建持久卷声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 ReadWriteMany 将卷附加到多个 Pod 来创建持久卷声明的最佳方法是什么?

What is the best way to create a persistent volume claim with ReadWriteMany attaching the volume to multiple pods?

基于 https://kubernetes.io/docs/concepts/中的支持表storage/persistent-volumes,GCEPersistentDisk 本身不支持 ReadWriteMany.

Based off the support table in https://kubernetes.io/docs/concepts/storage/persistent-volumes, GCEPersistentDisk does not support ReadWriteMany natively.

在 GCP GKE 世界中工作的最佳方法是什么?我应该使用像 CephFS 或 Glusterfs 这样的集群文件系统吗?是否有关于我应该使用哪些产品准备就绪的建议?

What is the best approach when working in the GCP GKE world? Should I be using a clustered file system such as CephFS or Glusterfs? Are there recommendations on what I should be using that is production ready?

我能够按照此处的步骤配置 NFS pod 部署 - https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266 但是它似乎有点hacky并添加另一层复杂性.它似乎也只允许一个副本(这是有道理的,因为磁盘不能被多次挂载)所以如果/当 pod 宕机时,我的持久存储也会如此.

I was able to get an NFS pod deployment configured following the steps here - https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266 however it seems a bit hacky and adds another layer of complexity. It also seems to only allow one replica (which makes sense as the disk can't be mounted multiple times) so if/when the pod goes down, my persistent storage will as well.

推荐答案

现在可以使用 Cloud Filestore.

首先创建一个 Filestore 实例.

First create a Filestore instance.

gcloud filestore instances create nfs-server
    --project=[PROJECT_ID]
    --zone=us-central1-c
    --tier=STANDARD
    --file-share=name="vol1",capacity=1TB
    --network=name="default",reserved-ip-range="10.0.0.0/29"

然后在 GKE 中创建一个持久卷.

Then create a persistent volume in GKE.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: fileserver
spec:
  capacity:
    storage: 1T
  accessModes:
  - ReadWriteMany
  nfs:
    path: /vol1
    server: [IP_ADDRESS]

[IP_ADDRESS] 在文件存储实例详细信息中可用.

[IP_ADDRESS] is available in filestore instance details.

您现在可以请求永久卷声明.

You can now request a persistent volume claim.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: fileserver-claim
spec:
  accessModes:
  - ReadWriteMany
  storageClassName: "fileserver"
  resources:
    requests:
      storage: 100G

最后,将卷挂载到您的 Pod 中.

Finally, mount the volume in your pod.

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - name: my container
    image: nginx:latest
    volumeMounts:
    - mountPath: /workdir
      name: mypvc
  volumes:
  - name: mypvc
    persistentVolumeClaim:
      claimName: fileserver-claim
      readOnly: false

解决方案详述如下:https://cloud.google.com/filestore/docs/访问文件共享

这篇关于如何在 GKE 中使用 ReadWriteMany 创建持久卷声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆