/ k8s-storage / devel / create-pvc/

CSI to claim Persistent Volumes (PVC/PV)

Once kadalu operator is started, and storage config is attached, we are ready to get started with PVC.

# File: sample-pvc.yaml
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv1
spec:
  storageClassName: kadalu.replica1
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

Create PVC using,

$ kubectl apply -f sample-pvc.yaml
persistentvolumeclaim/pv1 created

and check the status of PVC using,

$ kubectl get pvc
NAME   STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS     AGE
pv1    Bound    pvc-8cbe80f1-428f-11e9-b31e-525400f59aef   1Gi        RWO            kadalu.replica1  42s

Now, this PVC is ready to be consumed in your application pod. You can see the sample usage of PVC in an application pod by below:

# File: sample-app.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: pod1
  labels:
    app: sample-app
spec:
  containers:
  - name: sample-app
    image: docker.io/kadalu/sample-pv-check-app:latest
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - mountPath: "/mnt/pv"
      name: csivol
  volumes:
  - name: csivol
    persistentVolumeClaim:
      claimName: pv1
  restartPolicy: OnFailure
$ kubectl apply -f sample-app.yaml
pod1 created
© 2021 Kadalu Software Private Limited. All Rights Reserved.