我有一个需要永久磁盘的 pod。我在 us-central1-a 上运行了 1 个 pod,如果该区域出现故障,我想迁移到另一个区域而不会丢失数据到另一个区域 (us-central1-*)。
是否可以将 pod 迁移到另一个区域(我知道磁盘存在的地方)并将区域磁盘用于新区域中的 pod?
方法一
使用下面的StorageClass
我的 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 个是随机区域。当我故意减少并移出我的初始 pod 区域时,我会收到以下错误,除非我有幸选择了另一个随机配置的区域。这个功能是故意的,因为谷歌假设 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
我的 Pod 音量
卷:
- name: console-persistent-volume
persistentVolumeClaim:
claimName: my-pvc