gpt4 book ai didi

kubernetes - GKE : right way to mount same PV on multiple pods

转载 作者:行者123 更新时间:2023-12-03 16:33:42 25 4
gpt4 key购买 nike

我无法创建可以从不同 pod 使用的持久卷(1 次写入,另一次读取)。

尝试使用 gcePersistentDisk直接在 pod 规范中,如 k8s 页面上的示例(加上 readOnly ):

apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: gcr.io/google_containers/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
readOnly: true
volumes:
- name: test-volume
gcePersistentDisk:
pdName: my-data-disk
fsType: ext4
readOnly: true

然后在第二个 pod 规范中除了 readOnly 之外完全相同...但得到了 NoDiskConflict错误。

第二种方法是使用 PersistentVolumePersistentVolumeClaim像这样:
apiVersion: v1
kind: PersistentVolume
metadata:
name: data-standard
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
gcePersistentDisk:
fsType: ext4
pdName: data

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-standard-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi

但现在我收到一个错误告诉我:
MountVolume.MountDevice failed for volume "kubernetes.io/gce-pd/xxx" (spec.Name: "yyy") pod "6ae34476-6197-11e7-9da5-42010a840186" (UID: "6ae34476-6197-11e7-9da5-42010a840186") with: mount failed: exit status 32 Mounting command: mount Mounting arguments: /dev/disk/by-id/google-gke-cluster-xxx /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gke-cluster-xxx [ro] Output: mount: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
Error syncing pod, skipping: timeout expired waiting for volumes to attach/mount for pod "default"/"my-deployment". list of unattached/unmounted volumes=[data]

那么使用具有多个 Pod 的 GCE 磁盘的正确方法是什么。

PS:Kubernetes 1.6.6

最佳答案

根据 https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes , GCE Disks 不支持 ReadWriteMany。我不确定这是否可以解释问题,但我建议您尝试另一种兼容的卷类型。

关于kubernetes - GKE : right way to mount same PV on multiple pods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44930869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com