I am defining my first Kubernetes deployment and would like to define a container that mounts persistent storage at two points, say like this (in Deployment.yaml inside spec.template.spec.containers.-):

- name: volume1
  mountPath: /var/log/app
- name: volume2
  mountPath: /var/lib/app

I understand from Kubernetes' MEAN stack sample that I should be able to create two corresponding GCE disks, say like this:

gcloud compute disks create --size 10GB volume1
gcloud compute disks create --size 10GB volume2

I currently contemplate two disks instead of one only because I need to mount at two different paths. Can a Kubernetes service mount different "portions" (possibly partitions) of a single volume/disk at different paths?

The specification of v1.VolumeMount suggests that this may not be possible at the level of the service specification, because it supports only the fields name, readOnly, and mountPath.

These answers suggests that it might be possible on the level of EXT4 partitions, but that this would require the the volume to be read-only. Even in the read-only case (which does not meet my requirements), how would I go about creating a GCE disk with partitions?

(migrated from StackOverflow)

  • Possible duplicate here – Drux Jul 26 '16 at 16:27

A Kubernetes persistent volume (or GCE persistent disk, which is approximately the same thing) can only be mounted to one point in your pod's directory structure. But once mounted, you can certainly create bind mounts or symbolic links to organize its files however you wish. You can also change the configuration of your applications to read and write to a subdirectory of wherever you mounted the persistent volume, but that would take more work.


I have decided on using (symbolic links to) multiple subdirectories inside a PD with a single partition instead. This is also suggested here (Kubernetes #20835).

  • P.S. The fact that spec.template.spec.volumes.[*].gcePersistentDisk supports a field partition was misleading me for a bit. – Drux Jul 29 '16 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.