Can we write to persistent storage from outside of Kubernetes cluster on-prem?

Viewed 38

I am new to the storage concepts in Kubernetes. I need to have some common persistent storage in the Kubernetes cluster but also to be able to write to it from outside of the cluster on-prem environment..

So my question is, Can we have some persistent storage (of a file system) in Kubernetes cluster that can be shared among different pods, and also applications from outside the Kubernetes cluster will be able to write to it? if yes, what is the proper architecture for it? how can I access that persistent storage from outside of the cluster?

if it's not possible, is there a better way to achieve my need to have some common database file system for podes in the cluster and applications outside the cluster?

2 Answers

Having a filesystem shared inside the cluster between multiple pods is doable with any persistent volume marked as ReadWriteMany, like a NFS. However for the NFS you will need to have a Kubernetes "addon" that manages its creation and deletion that is specific to your infrastructure.

I don't know how it will react if it is modified from outside the cluster but if what you need is just to have a database shared between the cluster an outsider application then it may be easier to have a regular database on a machine outside the cluster.

In fact you mostly want a distributed database on a kubernetes cluster for high availability, not performance, and most implementation seem to favor local storage with synchronization implemented inside the application (leader election and so on) over shared volumes.

If you want performances, you may take a look at sharding your database.

Take look at NFS server/protocol.

You can use it as both inside the K8s cluster as nfs PersistentVolume and outside the cluster.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-nfs-pv
spec:
  storageClassName: nfs
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 10Gi
  persistentVolumeReclaimPolicy: Retain
  mountOptions: # https://linux.die.net/man/5/nfs
  - nfsvers=4.2
  - port=32049
  nfs:
    path: /exports
    server: your.nfs.server.host-or-ip
    readOnly: false

You can also use object-storage like MinIO (S3 protocol). More:

Related