This is a group of short to-the-point notes as comments in the code. For comprehensive documentation, look at the official docs.

Notes:

  1. Manually linking the PV and PVC like this means even if the PVC is deleted PV won’t be deleted automatically. You’ve to delete the PV manually.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
apiVersion: v1
kind: PersistentVolume
metadata:
  # even if the PV name is different from the PVC name, as long as the storage size 
  # and the PV storage class match with the PVC, kubernetes will link them together
  name: 'suraj-bankar2' 
spec:
  accessModes: ['ReadWriteOnce']
  capacity:
    # storage here needs to match with the storage field in the PVC
    # if that doesn't happen, Kubernetes won't bind this PV to the `suraj-bankar` PVC
    storage: 100Mi
  persistentVolumeReclaimPolicy: Delete
  # our PV needs to have the same storage class 
  # (or the default storage class should be `standard`). 
  # If the storage classes don't match, PV and PVC won't be linked.
  storageClassName: standard 

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: 'suraj-bankar'
spec:
  accessModes: ['ReadWriteOnce']
  storageClassName: standard 
  volumeName: suraj-bankar2 
  resources:
    requests:
      storage: '100Mi'