带有aws的kubernetes动态PV处于待定状态

时间:2019-02-07 18:07:11

标签: kubernetes amazon-eks kubernetes-pvc aws-eks

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

我已根据此doc创建了存储类,用于动态持久性卷创建

这是我的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)

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

1 个答案:

答案 0 :(得分:1)

由于群集没有默认的StorageClass,因此我不得不在storageClassName: aws-gp2上添加volumeClaimTemplates,这有助于解决此问题

喜欢

  volumeClaimTemplates:
  - metadata:
      namespace: staging
      name: data
      labels:
        name: redis-cluster
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: aws-gp2
      resources:
        requests:
          storage: 100Mi