我的 GKE 部署由 N 個 Pod(可能在不同的節點上)和一個共享卷組成,該卷由GCP動態配置pd.csi.storage.gke.io并且是 GCP 中的永久磁盤。我需要在 pod 上線之前用資料初始化這個磁盤。
我的問題是我需要設定accessModes并ReadOnlyMany能夠以只讀模式將其安裝到跨不同節點的所有 pod,我認為這實際上會導致無法以寫入模式將其安裝到initContainer.
這個問題有解決方案嗎?對這個問題的回答為每個 pod 都安裝了自己的磁盤的情況提出了一個很好的解決方案,但是我需要在所有 pod 之間共享一個磁盤,因為我的資料非常大。
uj5u.com熱心網友回復:
使用 GKE 1.21 及更高版本,您可以在集群中啟用托管 Filestore CSI 驅動程式。您可以為新集群啟用驅動程式
gcloud container clusters create CLUSTER_NAME \
--addons=GcpFilestoreCsiDriver ...
或更新現有集群:
gcloud container clusters update CLUSTER_NAME \
--update-addons=GcpFilestoreCsiDriver=ENABLED
完成后,創建一個存盤類(或讓或平臺管理員這樣做):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: filestore-example
provisioner: filestore.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
tier: standard
network: default
之后,您可以使用 PVC 和動態配置:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: podpvc
spec:
accessModes:
- ReadWriteMany
storageClassName: filestore-example
resources:
requests:
storage: 1Ti
uj5u.com熱心網友回復:
...I need to have one disk shared among all pods
你可以試試 Filestore。首先,您創建一個 FileStore實體并將您的資料保存在 FileStore 卷上。然后在集群上安裝FileStore 驅動程式。最后,您與需要使用 PersistentVolume 讀取資料的 pod 共享資料,該 PersistentVolume參考上面的 FileStore 實體和卷。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/464624.html
