Is it possile to create a pvc for a pv

8/21/2019

I have a PV:

pvc-6b1a6054-c35e-11e9-afd7-0eeeeb629aaa   100Gi      RWO            Delete           Bound   pipeline-aws/mln13-0                 performance             28h

Can I create a pvc to bind to this pv?

kubectl get pvc

doesn't show pvc mln13-0

-- codec
kubectl
kubernetes

2 Answers

8/22/2019

Your pvc has bound to pv, in namespace pipeline-aws, so you can show your pvc with command:

kubectl get pvc -n pipeline-aws
-- Kun Li
Source: StackOverflow

8/22/2019

In your case Persistent Volume is automatically created when it is dynamically provisioned. In following example, the PVC is defined as mln13-0, and a corresponding PV pvc-6b1a6054-c35e-11e9-afd7-0eeeeb629aaa is created and associated with PVC automatically.

Notice that the RECLAIM POLICY is Delete (default value), which is one of the two possible reclaim policies, the other one is Retain. In case of Delete, the PV is deleted automatically when the PVC is removed, and the data on the PVC will also be lost.

On the other hand, PV with Retain policy will not be deleted when the PVC is removed, and moved to Release status, so that data can be recovered by Administrators later.

With following command you can list all of PVCs in all namespaces along with the corresponding PVs:

$ kubectl get pvc --all-namespaces

Also what is interesting the PV can be accessed by any project/namespace, however once it is bound to a project, it can then only be accessed by containers from the same project/namespace. PVC is project/namespace specific, it means that if you have mulitple projects you would need to have a new PV and PVC for each project.

You can read more about binding in official K8S documentation.

-- muscat
Source: StackOverflow