In my humble opinion, Google Kubernetes Engine (previously known as Google Container Engine) is the best kubernetes implementation among all the cloud providers. It is THE easiest to set up as well. Because of that, we’ve been using GKE extensively on many of our projects. And recently, I came across a use case that is not documented at all (at least I couldn’t find any documentation) - Using an SSD with Persistent Volume (PV) in GKE

Turns out, it is not very straight forward. So, I decided to write a blog post explaining just that.

Creating an SSD persistent volume in GKE Link to heading

First of all, we need to add the SSD storage class so that you can start creating PVs from SSD.

Create ssd-storage-class.yml with the following content

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ssd
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd

Create the storage class

kubectl create -f ssd-storage-class.yml

Once that is done, make sure that the new storage class is created and ready to use

kubectl get sc

You should see something like below

➜ kubectl get sc
NAME                 TYPE
ssd                  kubernetes.io/gce-pd
standard (default)   kubernetes.io/gce-pd

Great. We have created the storage class. Now all we can easily create persistent volumes using the newly created storage class

Example: Link to heading

Create ssd-pv-demo.yml with the following contents

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ssd-pv-demo
  labels:
    name: ssd-pv-demo
spec:
  accessModes: [ "ReadWriteOnce" ]
  storageClassName: ssd
  resources:
    requests:
      storage: 10Gi

the storageClassName is what defines whether the disk is an SSD or a standard drive.

Alright, that’s all.