Formating NVMe disks on IOPS nodes
When you order IOPS nodes for your OVHcloud Managed Kubernetes cluster, the NVMe disks are neither partitioned nor formatted, therefore they cannot be used to create Kubernetes persistent volumes. In this tutorial we are going to guide you on how to easily achieve the partitioning and the formatting of your NVMe disks on your existing nodes but also on future ones.
Why using Kubernetes IOPS nodes?
Kubernetes IOPS nodes are very useful to run applications that rely heavily on disk performance, as IOPS nodes have one or several local NVMe SSD disks. Applications like Elasticsearch for indexation or Spark for big data would be very good candidate for this.
Before you begin
This tutorial assumes that you already have a working OVHcloud Managed Kubernetes cluster, and some basic knowledge of how to operate it. If you want to know more on those topics, please look at the deploying a Hello World application documentation.
Let’s create a daemonset to partition and format our available NVMe disks
To be sure that all our nodes with NVMe disks are properly prepared, we are going to create a daemonset. This daemonset will create a new pod on every node in the cluster that has the label disktype=nvme. If the node is an IOPS node and the NVMe disks are not already partitioned, the pod will proceed with the partitioning and the formatting of the NVMe disks.
One huge advantage of this method is the fact that if we add a new IOPS node later in the cluster, the disk will be automatically prepared by the daemonset as soon as we add the label disktype=nvme to the new node.
Let's create a format-nvme-configmap.yaml file:
In this example we are going to split the NVMe disks in 3 equal sized partitions. Each partition might be later associated to a Kubernetes persistent volume. This means that we will be able to create three local NVMe persistant volumes per node. If you need more or less partitions, you can change the partition_number parameter in the configmap definition.
Create the configmap:
Let’s create a format-nvme-daemonset.yaml file:
And deploy the daemonset on the cluster:
Currently, the daemonset should not have started any pod in our cluster as none of our nodes has the label disktype=nvme.
Let's fix this by adding the disktype=nvme label on our IOPS nodes. In this example our IOPS nodes are called node-nvme-1 and node-nvme-2, please modify this accordingly.
We should now have one format-nvme pod running on each of our cluster node that has the label disktype=nvme:
Under the hood all our IOPS nodes should now have three partitions /dev/nvme/nvme1, /dev/nvme/nvme2, and /dev/nvme/nvme3 created on their NVMe disk and these partitions should be of equal size.
Create and use a local NVMe persistant volume
First we need to create a new storage class. Let’s create a local-nvme-storage-class.yaml file:
And apply this to our cluster:
Then let’s create a new persistent volume on the first partition of our first IOPS node using our local NVMe storage class. In this example the node is called node-nvme-1 and the partition used is the first one /dev/nvme/nvme1, please modify this accordingly. To do this, let’s create a local-nvme-persistent-volume.yaml file:
And apply this to create the persistent volume:
Then, we need to create a persistent volume claim. Let’s create a local-nvme-persistent-volume-claim.yaml file:
And apply this to create a 50Gi claim:
Let’s now create an Nginx pod using the persistent volume claim as his webroot folder. For this, let’s create a local-nvme-nginx-pod.yaml file:
And deploy the Nginx pod:
Let's enter inside the Nginx container to create a file on the NVMe persistent volume:
Create a new index.html file:
and exit the Nginx container:
Let's try to access our new web page:
and open the URL http://localhost:8001/api/v1/namespaces/default/pods/http:local-nvme-nginx:/proxy/
Now let's try to see if the data is persistent by deleting our current Nginx pod:
Then, let's try to create a new one:
We should now check that our web page is still accessible:
and browse the same URL http://localhost:8001/api/v1/namespaces/default/pods/http:local-nvme-nginx:/proxy/
Clean your cluster
Let's remove the Nginx pod used for testing:
Let's remove the persistent volume claim used for testing:
And finally let's remove the persistent volume used for testing:
Although the persistent volume is removed from our Kubernetes cluster, the data are still present on the node disk.
Let's identify the name of our format-nvme pod running on our node-nvme-1:
And enter inside the container:
We can now reformat our /dev/nvme/nvme1 logical volume:
And exit the container:
If you don't plan to add more IOPS nodes to your cluster, you should remove the daemonset. It is of course still possible to redeploy it later without automatically reformat the existing partitions.
Go further
-
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for assisting you on your specific use case of your project.
-
Join our community of users on https://community.ovh.com/en/.