Error “pod has unbound immediate PersistentVolumeClaim” during statefulset deployment

痴心易碎 提交于 2021-02-16 20:26:33

问题


I am deploying stolon via statefulset (default from stolon repo). I have define in statefulset config

volumeClaimTemplates:     
    - metadata:    
        name: data   
      spec:   
        accessModes: ["ReadWriteOnce"]   
        storageClassName: stolon-local-storage  
        resources:
          requests:
            storage: 1Gi

and here is my storageClass:

apiVersion: storage.k8s.io/v1   
kind: StorageClass   
metadata:   
  name: stolon-local-storage  
provisioner: kubernetes.io/no-provisioner  
volumeBindingMode: WaitForFirstConsumer

statefulset was created fine, but pod has error: pod has unbound immediate PersistentVolumeClaims

How can I resolve it?


回答1:


pod has unbound immediate PersistentVolumeClaims

In this case pvc could not connect to storageclass because it wasn't make as a default.

Depending on the installation method, your Kubernetes cluster may be deployed with an existing StorageClass that is marked as default. This default StorageClass is then used to dynamically provision storage for PersistentVolumeClaims that do not require any specific storage class. See PersistentVolumeClaim documentation for details.

Command which can be used to make your new created storageclass a default one.

kubectl patch storageclass <name_of_storageclass> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

Then You can use kubectl get storageclass and it should look like this

NAME                 PROVISIONER               AGE
stolon-local-storage   (default)   kubernetes.io/gce-pd      1d


来源:https://stackoverflow.com/questions/58607949/error-pod-has-unbound-immediate-persistentvolumeclaim-during-statefulset-deplo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!