I'm having trouble to create a persistent volume that I can use from different pods (1 write, another read).
Tried to use gcePersistentDisk
directly in the pod spec like in the example on the k8s page (plus 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
Then in the second pod spec exactly the same except the readOnly
... but got an NoDiskConflict
error.
Second approach is to use PersistentVolume
and PersistentVolumeClaim
like this:
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
But now I get an error telling me:
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]
So what is the correct way of using a GCE disk with multiple pods.
PS: Kubernetes 1.6.6
According to https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes, GCE Disks do not support ReadWriteMany. I am not sure if this explains the issue but I would advise you to try another compatible Volume type.
Instead of ReadWriteMany
, can you use ReadOnlyMany
?
Accessmodes:
ReadWriteOnce – the volume can be mounted as read-write by a single node
ReadOnlyMany – the volume can be mounted read-only by many nodes
ReadWriteMany – the volume can be mounted as read-write by many nodes
GCE persistent disk do not support ReadWriteMany
Here is the list of providers and supported accessmodes:
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With