To configure a PersistentVolume in Kubernetes, you need to create a YAML file that defines the PersistentVolume resource. Below is an example configuration:
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-persistent-volume
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/data
Steps to Configure PersistentVolume:
-
Create a YAML file (e.g.,
persistent-volume.yaml) with the above content. -
Apply the configuration using the following command:
kubectl apply -f persistent-volume.yaml -
Verify the PersistentVolume has been created:
kubectl get pv
This will create a PersistentVolume with a capacity of 10Gi, accessible in ReadWriteOnce mode, and using the specified host path for storage. Adjust the capacity, accessModes, and hostPath as needed for your use case.
