kubernetes

How To Create PVC In Kubernetes?

Let’s understand what contents make a PVC file and what exactly it means.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: maintainer-pvc
  namespace: <namespace-name>
spec:
  storageClassName: <storageClassName>
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
  • apiVersion represents from which group Kind belongs.
  • kind represents the type of Kubernetes objects.
  • metadata defines the details of the PVC, such as, in which namespace you want to create the PVC, what should be the name of the PVC, etc.
  • spec defines the specification for the PVC.
    • storageClassName – It defines which type of storage class should PVC use.
    • accessModes – It define which type of access should be applicable.
      • ReadWriteOnce – the volume can be mounted as read-write by a single node
      • ReadOnlyMany – the volume can be mounted read-only by many nodes
      • ReadWriteMany – the volume can be mounted as read-write by many nodes
    • resources define how much resource is required by the PVC.

To create PVC in the Kubernetes cluster run the below command

kubectl create -f <pvc.yaml>

MtroView team is giving its best & working hard to provide the content to help you understand things better in simple terms. We are heartily open to receiving suggestions to improve our content to help more people in society. Please write to us in the form of a comment or can also send an email to mtroview@gmail.com

Leave a Comment

Your email address will not be published. Required fields are marked *