gpt4 book ai didi

google-kubernetes-engine - 在GKE中,我们可以通过PVC对象创建持久化卷的区域或区域吗?

转载 作者:行者123 更新时间:2023-12-04 03:51:33 25 4
gpt4 key购买 nike

我希望我的持久卷驻留在特定区域,比如 us-central1-a,但我想通过 PVC 部署它,而不是通过直接创建 PV 对象。这在 GKE 中可能吗?

最佳答案

您应该使用 Regional persistent disks

To enable dynamic provisioning of regional persistent disks, create a StorageClass with the replication-type parameter, and specify zone constraints in allowedTopologies.

For example, the following manifest describes a StorageClass named regionalpd-storageclass that uses standard persistent disks and that replicates data to the europe-west1-b and europe-west1-c zones:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: regionalpd-storageclass
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-standard
replication-type: regional-pd
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: topology.kubernetes.io/zone
values:
- europe-west1-b
- europe-west1-c

Create a PersistentVolumeClaim object, and use the storageClassName field to refer to the StorageClass you created. For example, the following manifest creates a PersistentVolumeClaim named regional-pvc and references the regionalpd-storageclass

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: regional-pvc
namespace: testns
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Gi
storageClassName: regionalpd-storageclass

The following manifest is an example Pod using the previously created PersistentVolumeClaim:

kind: Pod
apiVersion: v1
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: regional-pvc
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage
你可以关注这个 guide向你展示如何做到

关于google-kubernetes-engine - 在GKE中,我们可以通过PVC对象创建持久化卷的区域或区域吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64376275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com