persistentvolumeclaim "pv-delay-bind" not found kubernetes

9/4/2019

I specified:

This is Deployment:

apiVersion: apps/v1beta1
kind: Deployment
         ...
          volumeMounts:
            - name: volumepath
              mountPath: /data
          ports:
            - containerPort: 9200
              name: http
              protocol: TCP
      volumes:
        - name: volumepath
          persistentVolumeClaim:
          claimName: pv-delay-bind

This is persistentvolume:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-delay-bind
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 10Gi
  hostPath:
    path: /data/
    type: DirectoryOrCreate
  storageClassName: default1a
-- Jokky
kubernetes
persistent-volume-claims
persistent-volumes

1 Answer

9/4/2019

A Persistent Volume is different from a Persistent Volume Claim. Typically, when you use persistent volume claim you are using dynamic provisioning.

So you would need to define the persistent volume claim first and the volume should be created automatically.

First, delete your volume if you don't need it.

$ kubectl delete volume pv-delay-bind

Then create the claim:

$ echo '
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-delay-bind
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 10Gi
  storageClassName: default1a' | kubectl apply -f - 
-- Rico
Source: StackOverflow