大网数据广告活动
服务器运维问答

Can Kubernetes service mount multiple “portions” of a single GCE disk at the multiple mount paths?

· 52CE 我爱测

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.- ): volumeMounts: - name: vol…

问题原文

原帖链接 · Drux · CC BY-SA 3.0

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.-):

volumeMounts:
- 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)

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。