Kubernetes 用于Pvc和StorageClass故障切换的GKE区域磁盘

Kubernetes 用于Pvc和StorageClass故障切换的GKE区域磁盘,kubernetes,google-cloud-platform,google-kubernetes-engine,persistent-volumes,gce-persistent-disk,Kubernetes,Google Cloud Platform,Google Kubernetes Engine,Persistent Volumes,Gce Persistent Disk,我有一个pod需要一个持久磁盘。我有一个pod在us-central1-a上运行,如果该区域发生故障,我希望迁移到另一个区域,而不会将数据丢失到另一个区域(us-central1-*) 是否可以将pod迁移到另一个区域(我知道磁盘存在),并在新区域中为pod使用区域磁盘 方法1 使用下面的StorageClassmy pod始终无法声明任何这些,并且我的pod从未启动。我知道这个配置了所有区域的区域磁盘将在区域故障时使所有区域都可以使用该磁盘。我不明白为什么我不能要求任何这些 kind: Sto

我有一个pod需要一个持久磁盘。我有一个pod在us-central1-a上运行,如果该区域发生故障,我希望迁移到另一个区域,而不会将数据丢失到另一个区域(us-central1-*)

是否可以将pod迁移到另一个区域(我知道磁盘存在),并在新区域中为pod使用区域磁盘

方法1

使用下面的
StorageClass
my pod始终无法声明任何这些,并且我的pod从未启动。我知道这个配置了所有区域的区域磁盘将在区域故障时使所有区域都可以使用该磁盘。我不明白为什么我不能要求任何这些

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:
    - us-central1-a
    - us-central1-b
    - us-central1-c
    - us-central1-f
错误:我的PVC状态始终处于挂起状态

  Normal   NotTriggerScaleUp  106s                cluster-autoscaler  pod didn't trigger scale-up (it wouldn't fit if a new node is added):
      Warning  FailedScheduling   62s (x2 over 108s)  default-scheduler   0/8 nodes are available: 8 node(s) didn't find available persistent volumes to bind.
尝试2

此存储配置允许我在2/4个区域中运行pod,其中1个区域为初始区域,1个为随机区域。当我故意减少并移出我的初始pods区域时,我将得到以下错误,除非我足够幸运地选择了另一个随机配置的区域。这项功能是故意的,因为谷歌认为2区故障的可能性很低吗?如果其中一个出现故障,我是否需要在另一个区域配置另一个磁盘以防万一

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
错误:

Normal   NotTriggerScaleUp  4m49s                  cluster-autoscaler  pod didn't trigger scale-up (it wouldn't fit if a new node is added):
  Warning  FailedScheduling   103s (x13 over 4m51s)  default-scheduler   0/4 nodes are available: 2 node(s) had volume node affinity conflict, 2 node(s) were unschedulable.
  Warning  FailedScheduling   43s (x2 over 43s)      default-scheduler   0/3 nodes are available: 1 node(s) were unschedulable, 2 node(s) had volume node affinity conflict.
  Warning  FailedScheduling   18s (x3 over 41s)      default-scheduler   0/2 nodes are available: 2 node(s) had volume node affinity conflict.
我的pvc

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: my-pvc
  namespace: mynamespace
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
  storageClassName: regionalpd-storageclass
我的吊舱体积

卷数:

  - name: console-persistent-volume
    persistentVolumeClaim:
      claimName: my-pvc

谷歌云上的区域永久磁盘仅在两个区域可用,因此您必须将
StorageClass
更改为仅两个区域

请参阅上的StorageClass示例
文档中关于

的更多细节让我相信,只有当我将AllowedTopologys留空时,才会将我限制为2个区域。我想如果我指定的话,我可以得到所有的,显然不是这样的。您可以不指定AllowedTopologys。如果您这样做,当您创建一个使用此StorageClass的PersistentVolumeClaim的Pod时,一个区域永久性磁盘将配置两个区域。一个区域与Pod计划所在的区域相同。另一个区域从群集可用的区域中随机选取我没有看到另一个文档,直到您将其发布为“区域永久磁盘提供两个区域之间的同步复制”