Local SSDs

This page provides an overview of local SSD support in Kubernetes, and how to use local SSDs with Kubernetes Engine.

Overview

Local SSDs provide high-performance, ephemeral storage to every node in the cluster. Local SSDs provide higher throughput and lower latency than standard disks. Local caching and processing are suitable workloads for local SSDs.

You can create node pools with local SSDs within your cluster's machine type limits and your project's quotas.

Restrictions

Ensure that you are aware of the following restrictions as you use local SSDs:

  • Because local SSDs are physically attached to the node's host virtual machine instance, any data stored in them only exists on that node. As the data stored on the disks is local, ensure that your application is resilient to having this data being unavailable.
  • A Pod that writes to a local SSD might lose access to the data stored on the disk if the Pod is rescheduled away from that node. Additionally, upgrading a node causes the data to be erased.
  • You cannot add local SSDs to an existing node pool.

Using local SSDs

The following section explains how to use local SSDs with Kubernetes Engine.

Console

You can create a cluster or node pool with local SSDs from the Kubernetes Engine menu in the Google Cloud Platform Console.

To create a cluster in which the default pool uses local SSD disks, perform the following steps:

  1. Visit the Kubernetes Engine menu in the Google Cloud Platform Console.

    Visit the Kubernetes Engine menu

  2. Click Create cluster.

  3. Configure your cluster as desired. Then, from the Local SSD disks (per node) field, enter the desired number of SSDs as an absolute number.
  4. Click Create.

To create a node pool with local SSD disks in an existing cluster:

  1. Visit the Kubernetes Engine menu in the Google Cloud Platform Console.

    Visit the Kubernetes Engine menu

  2. Select the desired cluster.

  3. Click Edit.
  4. From the Node pools menu, click Add node pool.
  5. Configure the node pool as desired. Then, from the Local SSD disks (per node) field, enter the desired number of SSDs as an absolute number.
  6. Click Save.

gcloud

To create a cluster or node pool with local SSDs using gcloud, specify the --local-ssd count flag.

To create a cluster in which the default pool uses local SSD disks, run the following command:

gcloud container clusters create [CLUSTER-NAME] --local-ssd-count [NUMBER-OF-DISKS]

where [NUMBER-OF-DISKS] is the desired number of disks as an absolute number.

To create a node pool with local SSD disks in an existing cluster:

gcloud container node-pools create [POOL-NAME] --cluster [CLUSTER-NAME} --local-ssd-count [NUMBER-OF-DISKS]

The --local-ssd-count specifies the number of local SSDs to be created per node. The maximum number varies by the machine type and region (see Local SSDs). When nodes are created, the local SSDs are automatically formatted and mounted on the host OS at the subdirectory /mnt/disks/, with each local SSD mounted at a "ssd#" directory.

Example

For example, if one creates a node pool with three local SSDs, the host OS mounts the disks at /mnt/disks/ssd0, /mnt/disks/ssd1 and /mnt/disks/ssd2. Your Kubernetes containers access the disks using the hostPath parameter in defined in your object's configuration file.

Here is an example Pod configuration file which references a local SSD, /mnt/disks/ssd0:

apiVersion: v1
kind: Pod
metadata:
  name: "test-ssd"
spec:
  containers:
  - name: "shell"
    image: "ubuntu:14.04"
    command: ["/bin/sh", "-c"]
    args: ["echo 'hello world' > /test-ssd/test.txt && sleep 1 && cat /test-ssd/test.txt"]
    volumeMounts:
    - mountPath: "/test-ssd/"
      name: "test-ssd"
  volumes:
  - name: "test-ssd"
    hostPath:
      path: "/mnt/disks/ssd0"
  nodeSelector:
    cloud.google.com/gke-local-ssd: "true"

What's next

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Kubernetes Engine