Hello, I followed the same steps and I’m facing a problem to create the volume using Storage Class.
The PVC is at Phase PENDING for a while and the GCE disk hasn’t been created.
I’ve created the storage class using the sc.yaml:
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: slow provisioner: kubernetes.io/gce-pd parameters: type: pd-standard replication-type: none
Then I’ve create the pvc.yaml:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: storageClassName: slow accessModes: - ReadWriteMany resources: requests: storage: 20G
I found the problem in this https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes.
ReadWriteMany: The Volume can be mounted as read-write by many nodes. PersistentVolumes that are backed by Compute Engine persistent disks don't support this access mode.
After changing the access mode from ReadWriteMany to ReadWriteOne, it worked fine.
However, I got a question now. Won’t pods in different nodes access the same storage? Would I need to use pod affinity to make sure the pods are running on the same node?
That’s right, multiple nodes can’t access the same PersistentVolume because a block device can only be written to by one node at a time. In order for you to be able to write to a volume using multiple nodes at the same time, you would need to use a volume such as NFS. Here is a link to the supported access modes for each volume type: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes