DigitalOcean吊舱具有未绑定的立即PersistentVolumeClaims

时间:2018-10-24 18:38:17

标签: redis kubernetes digital-ocean

我正在尝试在DigitalOcean的Kubernetes中运行Redis集群。 作为Poc,我只是尝试运行一个在网上找到的示例(https://github.com/sanderploegsma/redis-cluster/blob/master/redis-cluster.yml),当使用minikube在本地运行时,它可以适当地旋转Pod。

但是,在Digital Ocean上运行它时,总是出现以下错误:

  

警告失败调度3秒(x8超过17秒)默认调度程序窗格具有未绑定的立即PersistentVolumeClaims(重复4次)

鉴于我没有进行任何更改,因此我不确定为什么这样做不起作用。有人有建议吗?

编辑:一些其他信息

$ kubectl describe pvc  
Name:          data-redis-cluster-0
Namespace:     default
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  3m19s (x3420 over 14h)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set
Mounted By:  <none>

编辑:设置默认存储类可以部分解决问题! 但是,该节点现在无法找到可用的卷进行绑定:

kubectl描述pvc:

Name:          data-redis-cluster-0
Namespace:     default
StorageClass:  local-storage
Status:        Pending
Volume:        
Labels:        app=redis-cluster
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
Events:
  Type       Reason                Age                     From                         Message
  ----       ------                ----                    ----                         -------
  Normal     WaitForFirstConsumer  12m (x9 over 13m)       persistentvolume-controller  waiting for first consumer to be created before binding
  Normal     WaitForFirstConsumer  3m19s (x26 over 9m34s)  persistentvolume-controller  waiting for first consumer to be created before binding

kubectl描述pod redis-cluster-0

....
Events:
  Type     Reason            Age                  From               Message
  ----     ------            ----                 ----               -------
  Warning  FailedScheduling  16m (x25 over 17m)   default-scheduler  0/5 nodes are available: 1 node(s) had taints that the pod didn't tolerate, 4 node(s) didn't find available persistent volumes to bind.

kubectl描述sc

Name:                  local-storage
IsDefaultClass:        Yes
Annotations:           storageclass.kubernetes.io/is-default-class=true
Provisioner:           kubernetes.io/no-provisioner
Parameters:            <none>
AllowVolumeExpansion:  <unset>
MountOptions:          <none>
ReclaimPolicy:         Delete
VolumeBindingMode:     WaitForFirstConsumer
Events:                <none>

kubernetes管理器pod日志:

I1028 15:30:56.154131       1 event.go:221] Event(v1.ObjectReference{Kind:"StatefulSet", Namespace:"default", Name:"redis-cluster", UID:"7528483e-dac6-11e8-871f-2e55450d570e", APIVersion:"apps/v1", ResourceVersion:"2588806", FieldPath:""}): type: 'Normal' reason: 'SuccessfulCreate' create Claim data-redis-cluster-0 Pod redis-cluster-0 in StatefulSet redis-cluster success
I1028 15:30:56.166649       1 event.go:221] Event(v1.ObjectReference{Kind:"PersistentVolumeClaim", Namespace:"default", Name:"data-redis-cluster-0", UID:"76746506-dac6-11e8-871f-2e55450d570e", APIVersion:"v1", ResourceVersion:"2588816", FieldPath:""}): type: 'Normal' reason: 'WaitForFirstConsumer' waiting for first consumer to be created before binding
I1028 15:30:56.220464       1 event.go:221] Event(v1.ObjectReference{Kind:"StatefulSet", Namespace:"default", Name:"redis-cluster", UID:"7528483e-dac6-11e8-871f-2e55450d570e", APIVersion:"apps/v1", ResourceVersion:"2588806", FieldPath:""}): type: 'Normal' reason: 'SuccessfulCreate' create Pod redis-cluster-0 in StatefulSet redis-cluster successful
I1028 15:30:57.004631       1 event.go:221] Event(v1.ObjectReference{Kind:"PersistentVolumeClaim", Namespace:"default", Name:"data-redis-cluster-0", UID:"76746506-dac6-11e8-871f-2e55450d570e", APIVersion:"v1", ResourceVersion:"2588825", FieldPath:""}): type: 'Normal' reason: 'WaitForFirstConsumer' waiting for first consumer to be created before binding

2 个答案:

答案 0 :(得分:3)

此:

  

未设置存储类别

kubectl describe sc的输出为空表示没有存储类。

我建议为Digital Ocean安装CSI-driver。这将使用Kubernetes CSI接口创建一个do-block-storage类。

另一个选择是使用本地存储。使用local存储类:

$ cat <<EOF
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
EOF | kubectl apply -f -

如果没有在PVC中指定storageClassName,则无论哪种情况,您都可能需要将其设置为默认存储类:

$ kubectl patch storageclass local-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

$ kubectl patch storageclass do-block-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

答案 1 :(得分:1)

它是一个使用PersistentVolumeClaims

的statefulSet

您需要在群集中配置默认​​的storageClass,以便PersistentVolumeClaim可以从那里获取存储空间。

在minikube中,一个已经可用,因此可以成功执行而不会出现错误:

C02W84XMHTD5:ucp iahmad$ kubectl get sc --all-namespaces 
NAME                 PROVISIONER                AGE
standard (default)   k8s.io/minikube-hostpath   7d