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

Time:09-13

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?

CodePudding user response:

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.

CodePudding user response:

Take look at NFS server/protocol.

You can use it as both inside the K8s Cluster as nfs PersistentVolume and externally.

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
  • Related