2 Answers
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