pod has unbound PersistentVolumeClaims

巧了我就是萌 提交于 2019-11-26 15:52:45

问题


When I push my deployments, for some reason, I'm getting the error on my pods:

pod has unbound PersistentVolumeClaims

Here are my YAML below:

This is running locally, not on any cloud solution.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.16.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: ckan
  name: ckan
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: ckan
    spec:
      containers:
        image: slckan/docker_ckan
        name: ckan
        ports:
        - containerPort: 5000
        resources: {}
        volumeMounts:
            - name: ckan-home
              mountPath: /usr/lib/ckan/
              subPath: ckan
      volumes:
      - name: ckan-home
        persistentVolumeClaim:
          claimName: ckan-pv-home-claim
      restartPolicy: Always
status: {}

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ckan-pv-home-claim
  labels:
    io.kompose.service: ckan
spec:
  storageClassName: ckan-home-sc
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
  volumeMode: Filesystem
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ckan-home-sc
provisioner: kubernetes.io/no-provisioner
mountOptions:
  - dir_mode=0755
  - file_mode=0755
  - uid=1000
  - gid=1000

回答1:


You have to define a PersistentVolume providing disc space to be consumed by the PersistentVolumeClaim.

When using storageClass Kubernetes is going to enable "Dynamic Volume Provisioning" which is not working with the local file system.


To solve your issue:

  • Provide a PersistentVolume fulfilling the constraints of the claim (a size >= 100Mi)
  • Remove the storageClass-line from the PersistentVolumeClaim
  • Remove the StorageClass from your cluster

How do these pieces play together?

At creation of the deployment state-description it is usually known which kind (amount, speed, ...) of storage that application will need.
To make a deployment versatile you'd like to avoid a hard dependency on storage. Kubernetes volume-abstraction allows you to provide and consume storage in a standardized way.

The PersistentVolumeClaim is used to provide a storage-constraint alongside the deployment of an application.

The PersistentVolume offers cluster-wide volume-instances ready to be consumed ("bound"). One PersistentVolume will be bound to one claim. But since multiple instances of that claim may be run on multiple nodes, that volume may be accessed by multiple nodes.

A PersistentVolume without StorageClass is considered to be static.

"Dynamic Volume Provisioning" alongside with a StorageClass allows the cluster to provision PersistentVolumes on demand. In order to make that work, the given storage provider must support provisioning - this allows the cluster to request the provisioning of a "new" PersistentVolume when an unsatisfied PersistentVolumeClaim pops up.



来源:https://stackoverflow.com/questions/52668938/pod-has-unbound-persistentvolumeclaims

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