Report this

What is the reason for this report?

How to specify filesystem for Persistent Volumes in k8s cluster?

Posted on September 13, 2021

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:

...
        volumeMounts:
          - name: mongo-raw-volume-claim
            mountPath: /data/db
  volumeClaimTemplates:
  - metadata:
      name: mongo-raw-volume-claim
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: do-block-storage
      resources:
        requests:
          storage: 100Gi


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!

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.

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

e.g. example-storageclass.yml:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard-retain-xfs
provisioner: dobs.csi.digitalocean.com
parameters:
  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,

-Conrad

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.