1

我正在使用 aws-gp2 持久卷在 kube 上创建 redis-cluster。我正在使用redis-cluster.yml

我根据这个文档创建了存储类,用于动态持久化卷创建

这是我的 StorageClass 定义

    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: aws-gp2
    provisioner: kubernetes.io/aws-ebs
    parameters:
      type: gp2
      zones: us-west-2a, us-west-2b, us-west-2c
      fsType: ext4
    reclaimPolicy: Retain
    allowVolumeExpansion: true

当我尝试创建集群卷创建卡在pending状态时,检查日志后发现这个

  $ kubectl -n staging describe pvc data-redis-cluster-0
  Name:          data-redis-cluster-0
  Namespace:     staging
  StorageClass:
  Status:        Pending
  Volume:
  Labels:        app=redis-cluster
  Annotations:   <none>
  Finalizers:    [kubernetes.io/pvc-protection]
  Capacity:
  Access Modes:
  Events:
    Type    Reason         Age                From                         Message
    ----    ------         ----               ----                         -------
    Normal  FailedBinding  13s (x11 over 2m)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set

和事件

    $ kubectl -n staging get events
    LAST SEEN   FIRST SEEN   COUNT     NAME                                    KIND                    SUBOBJECT   TYPE      REASON             SOURCE                        MESSAGE
    10s         10s          1         redis-cluster.15816c6dc1d6c03a          StatefulSet                         Normal    SuccessfulCreate   statefulset-controller        create Claim data-redis-cluster-0 Pod redis-cluster-0 in StatefulSet redis-cluster success
    10s         10s          1         redis-cluster.15816c6dc2226fe0          StatefulSet                         Normal    SuccessfulCreate   statefulset-controller        create Pod redis-cluster-0 in StatefulSet redis-cluster successful
    8s          10s          3         data-redis-cluster-0.15816c6dc1dfd0cb   PersistentVolumeClaim               Normal    FailedBinding      persistentvolume-controller   no persistent volumes available for this claim and no storage class is set
    3s          10s          5         redis-cluster-0.15816c6dc229258d        Pod                                 Warning   FailedScheduling   default-scheduler             pod has unbound PersistentVolumeClaims (repeated 4 times)

有人指出这里有什么问题?

4

1 回答 1

3

由于 cluster 没有 default StorageClass,我不得不添加storageClassName: aws-gp2to volumeClaimTemplates,这帮助我解决了这个问题

像这样

  volumeClaimTemplates:
  - metadata:
      namespace: staging
      name: data
      labels:
        name: redis-cluster
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: aws-gp2
      resources:
        requests:
          storage: 100Mi
于 2019-02-11T19:17:42.110 回答