Middle
How to connect external storage to Kubernetes (PV/PVC, S3)?
sobes.tech AI
Answer from AI
In Kubernetes, external storage is usually connected using Persistent Volumes (PV) and Persistent Volume Claims (PVC).
Connecting via PV/PVC:
- An administrator creates a Persistent Volume that describes a specific storage (e.g., NFS, iSCSI, cloud disk).
- A user creates a Persistent Volume Claim — a request for a certain amount and type of storage.
- Kubernetes binds the PVC to an appropriate PV and mounts it into a pod.
Example PVC for NFS:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: ""
Connecting to S3: S3 is an object storage that does not support POSIX file systems directly, so in Kubernetes, special CSI drivers or third-party solutions are used:
- Using a CSI driver for S3 (e.g., csi-s3) — allows mounting S3 buckets as volumes.
- Using S3 SDK within applications for direct access to objects.
- Using tools like MinIO, which provide an S3-compatible interface over block storage.
Thus, for traditional block storage, PV/PVC are used, and for S3, special CSI drivers or direct API access are employed.