How to use persistent disk in a Replication Controller ? Google cloud / kubernetes

1/2/2016

I would like to use persistent disk in my replication controller but if i use a gcePersistentDisk the console returns me an error

ReadOnly must be true for replicated pods > 1, as GCE PD can only be mounted on multiple machines if it is read-only.

--
google-cloud-platform
kubernetes

1 Answer

1/2/2016

From the error message and from the docs:

A feature of PD is that they can be mounted as read-only by multiple consumers simultaneously. This means that you can pre-populate a PD with your dataset and then serve it in parallel from as many pods as you need. Unfortunately, PDs can only be mounted by a single consumer in read-write mode - no simultaneous readers allowed.

So you have two options to fix this:

  1. Set the replicas in your ReplicationController to 1
  2. Make the volume readOnly: true

    gcePersistentDisk:
      pdName: my-data-disk
      fsType: ext4
      readOnly: true
-- manojlds
Source: StackOverflow