How to create a PVC?

0258

To create a Persistent Volume Claim (PVC) in Kubernetes, follow these steps:

  1. Create a YAML file for the PVC. For example, you can name it pvc.yaml. Here is an example configuration:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: my-pvc
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi

    In this example:

    • The PVC is named my-pvc.
    • It requests 1Gi of storage.
    • The access mode is set to ReadWriteOnce, meaning it can be mounted as read-write by a single node.
  2. Apply the PVC configuration using the kubectl command:

    kubectl apply -f pvc.yaml

This command will create the PVC in your Kubernetes cluster. You can check the status of the PVC by running:

kubectl get pvc

This will show you the details of the PVC, including whether it is bound to a Persistent Volume (PV).

0 Comments

no data
Be the first to share your comment!