I have an application which accesses a couple of files from a directory. I went through kubernetes volumes and persistent volumes and volume claims. this is a multi-node kubernetes cluster. do we have any direct solution which can be used which does not need any external storage like a nfs server etc?
I have a VM server from where i execute my kubernetes commands. I am new to kubernetes so please help me with this.
Also i was looking at local persistent volume. is there a link which i can go through for an example. I am looking at local https://kubernetes.io/docs/concepts/storage/volumes/#local
But the example does not explain what below are under nodeAffinity:
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 100Gi
# volumeMode field requires BlockVolume Alpha feature gate to be enabled.
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /mnt/disks/ssd1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- example-node
This depends on your use case, if the files you want to share across the cluster are more than a few megabytes in size, you'll need some kind of storage operator. Local storage is probably not what you're looking for.
If the files are small, such as configuration files or ssh keys or similar you can use a kubernetes configmap (or secret). This will allow you to setup a few files or directories with a few files. Checkout the documentation
If however you want to share a few hundred megabytes or gigabytes of files, you need a storage provider with your cluster.
If you are using a cloud provider, such as Google, AWS or Azure, this should be straightforward, you need to create a persistent disk with your cloud provider and copy your required data onto the disk. Once that's done, simply follow the guide for the relevant cloud providers:
(@justcompile pointed out that AWS doesn't support multiple read-only mounts to instances, I was unable to find similar information for Azure)
If however, you're running your own kubernetes cluster on "baremetal", you'll have to setup either an NFS server, a Ceph cluster and probably use something like rook on top.