如何预填充ReadOnlyMany永久卷 [英] How to pre-populate a ReadOnlyMany Persistent Volume
问题描述
我正在尝试在GKE中创建一个使用多个副本的部署.我有一些静态数据,希望在每个吊舱中都可以使用.此数据将不会更新,不需要写入.
I am trying to create a deployment in GKE that uses multiple replicas. I have some static data which I want to have available in every pod. This data will not be updated, no write is required.
我决定将PV与ReadOnlyMany存储类一起使用.问题是,我不知道如何实际将数据传输到该卷-因为它是只读的.我尝试使用
I decided to use a PV with a corresponding PVC with the ReadOnlyMany storage class. The thing is, I do not know how to actually transfer my data to the volume - since it is read-only. I tried using
gcloud compute scp /local/path instance:/remote/path
但是,当然,我得到一个权限错误.然后,我尝试通过控制台创建新的PV.我使用
but of course, I get a permission error. I then tried creating a new PV via the console. I attached it to a VM with
gcloud compute instances attach disk
安装并格式化磁盘,传输数据,卸载磁盘,将其与VM分离,并按照
mounted and formatted the disk, transfered my data, unmounted the disk, detached it from the VM and finally created a PVC following the documentation. I changed the storage class to ReadOnlyMany, the only difference.
但是,当我尝试将部署扩展到多个副本时,仍然收到错误消息,表明磁盘已经连接到另一个节点.
But still, when I'm trying to scale my deployment to more than one replicas I get an error saying the disk is already attached to another node.
那么,如何创建要在ReadOnlyMany中使用的卷并用数据填充磁盘?还是因为不需要写入而有更好的方法?
So, how can I create a volume that is to be used in ReadOnlyMany and populate the disk with data? Or is there a better approach since no write is required?
预先感谢
推荐答案
为我工作.在Pod模板中使用持久卷声明时是否指定了readOnly: true
?
Worked for me. Have you specified readOnly: true
when using persistent volume claim in the Pod template?
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: my-readonly-pvc
readOnly: true
在此处查看详细信息 https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks
See details here https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks
这篇关于如何预填充ReadOnlyMany永久卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!