How to use a Google Cloud Persistent Disk (PD) as a Persistent Volume (PV) in Kubernetes 什麼是 Persistent Volume(PV) Persistent Volume(PV)是 Kubernetes 中用來管理儲存資源的抽象化物件。系統管理員可以透過 PV 來管理集群中的實體儲存媒體。 要怎麼使用 Persistent Volume (PV) 要使用 Persistent Volume(PV),首先需要宣告 Persistent Volume Claim(PVC),並透過 PVC 來要求儲存空間。一旦 PVC 被宣告,Kubernetes 就會根據 PVC 中指定的條件尋找適合的 PV 來滿足 Pod 的需求,並將 PV 掛載到 Pod 中。 在 Google Cloud 的公有雲服務裡提供了一種叫做 Cloud Persistent Disk 的服務,它是一種持久性的存儲解決方案,可供 Kubernetes 中的應用程式使用。若想要在 Kubernetes 中使用 Cloud Persistent Disk 作為 Persistent Volume(PV),可參考以下作法: 方法一 Static Provisioning: 在 GCP 上建立 Cloud Persistent Disk(PD): bash gcloud compute disks create my-disk --size=10GB --zone=us-central1-a 建立 PersistentVolume (PV) YAML: yaml apiVersion: v1 kind: PersistentVolume metadata: name: my-pv spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain gcePersistentDisk: pdName: my-disk fsType: ext4 建立 PersistentVolumeClaim (PVC) YAML: yaml...