How to specify filesystem for Persistent Volumes in k8s cluster?

I have a Kubernetes cluster with a deployment which uses automatically provisioned block storage. My question is:

How can I specify the filesystem for the Persistent Volume? I would like for the Persistent Volume to be created with XFS in my case (my service is a MongoDB which recommends XFS filesystem).

Here is the section from my manifest for the Claim and volume mount:

          - name: mongo-raw-volume-claim
            mountPath: /data/db
  - metadata:
      name: mongo-raw-volume-claim
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: do-block-storage
          storage: 100Gi

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@BobbyKo In your K8s StorageClass manifest file, you’ll need to set the fsType as follows:

e.g. example-storageclass.yml:

kind: StorageClass
  name: standard-retain-xfs
  fsType: xfs
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer

For further information regarding this, I recommend taking a look at the following documentation here.

I wish that it helps and all the best.

Think different and code well,