pod has unbound PersistentVolumeClaims

10/5/2018

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
-- soniccool
kubernetes
persistent-storage

1 Answer

10/5/2018

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.

-- Florian Breisch
Source: StackOverflow