本文介绍了DigitalOcean Pod具有未绑定的立即PersistentVolumeClaims的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to run a Redis cluster in Kubernetes in DigitalOcean.As a poc, I simply tried running an example I found online (https://github.com/sanderploegsma/redis-cluster/blob/master/redis-cluster.yml), which is able to spin up the pods appropriately when running locally using minikube.

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

However, when running it on Digital Ocean, I always get the following error:

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

Given that I am not changing anything, I am not sure why this would not work. Does anyone have any suggestions?

一些其他信息

$ 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>

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

setting the default storage class partially resolved the problem!However, the node is now not able to find available volumes to bind:

kubectl描述pvc:

kubectl describe 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

kubectl describe 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

kubectl describe 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日志:

kubernetes manager pod logs:

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

推荐答案

此:

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

And an empty output for kubectl describe sc means that there's no storage class.

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

I recommend installing the CSI-driver for Digital Ocean. That will create a do-block-storage class using the Kubernetes CSI interface.

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

Another option is to use local storage. Using a local storage class:

$ 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,则可能需要将其设置为默认存储类:

Then for either case you may need to set it as a default storage class if you don't specify storageClassName in your PVC:

$ 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"}}}'

这篇关于DigitalOcean Pod具有未绑定的立即PersistentVolumeClaims的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 11:29