Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to sync a folder in kubernetes statefulset

We are trying to create a solution where we want to replicate changes made to a folder inside any of the pods of the Statefulset. Any file changes inside that folder on any POD should also reflect in other pods. Is there a sidecar solution for this requirement? Because we know that Statefulset will create separate PVs for each POD and there won’t be any common mount across the pods of the Statefulset.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can try using the NFS or file system like EFS using that you will be able to implement the ReadWritemany.

For ref Azure File.

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: statefulset-azurefile
  labels:
    k8s-app: nginx
    version: v1
spec:
  serviceName: statefulset-azurefile
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: nginx
        version: v1
    spec:
      containers:
      - name: statefulset-azurefile
        image: nginx
        volumeMounts:
        - name: persistent-storage
          mountPath: /mnt/azurefile
  volumeClaimTemplates:
  - metadata:
      name: persistent-storage
      annotations:
        volume.beta.kubernetes.io/storage-class: azurefile
    spec:
      accessModes: [ "ReadWriteMany" ]
      resources:
        requests:
          storage: 5Gi

Demo : https://github.com/andyzhangx/demo/tree/master/linux/statefulset

If volumeClaimTemplates not work as expected use the persistentVolumeClaim

Article to read about ReadWriteMany access Mode :https://docs.microsoft.com/en-us/azure/aks/azure-files-volume

If you are on other cloud providers like GCP, AWS, Oracle(OCI) provides different file services.

  • GCP- Filestore
  • AWS- EFS
  • OCI- Filestorage

OCI article if you want to explore : https://enabling-cloud.github.io/oci-learning/manual/StaticPersistentVolumeOnOCI.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading