方法 1(kubernetes 卷附加到 google 永久磁盘,kubernetes 卷声明附加到 kubernetes 卷)
apiVersion: v1
kind: PersistentVolume
metadata:
name: volume-1
spec:
storageClassName: ""
capacity:
storage: 50Gi
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: pd-test-1
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pv-claim-1
spec:
storageClassName: ""
volumeName: volume-1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
方法 2(Kubernetes 卷声明直接附加到 google 永久磁盘)
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pv-claim-1
spec:
volumeName: pd-test-1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
方法3(pod直接使用googlepersistent disk docs)
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
# This GCE PD must already exist.
gcePersistentDisk:
pdName: my-data-disk
fsType: ext4
我不确定在哪种情况下应该使用哪种方法。
如果我想在谷歌永久磁盘上存储数据,三种方法有什么区别?我应该使用哪一种?