Overview of Local SSD support

This page provides an overview of Local SSD support in Kubernetes, and how to use it with Google Container Engine.

Introduction

Local SSDs are physical devices attached to the virtual machine instance. GKE has added the ability for nodes to be created with them, up to the machine limits and the project’s quota.

When to use local SSD support

Local SSDs provide higher throughput and lower latency than standard disks. But they come with a major caveat: because they are physically attached to the node's host virtual machine instance, any data stored in them only exists on that node. A pod that writes to a local SSD may lose access to that data if it gets rescheduled away from that node. Also, upgrading a node causes the data to be completely lost. Please be aware of these restrictions as you use local SSDs.

How local SSD support works

Creating nodes with local SSD

To create a container cluster or node pool with local SSDs, use the --local-ssd-count option when creating your cluster or node pool:

Creating a cluster where the default pool has local SSD disks:

gcloud container clusters create NAME --local-ssd-count=#

Creating a node pool with local SSD disks to a container cluster:

gcloud container node-pools create NAME --cluster CLUSTER --local-ssd-count=#

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.

For example, if one creates a node pool with three local SSDs, the host OS mounts the disks at the following directories:

/mnt/disks/ssd0
/mnt/disks/ssd1
/mnt/disks/ssd2

They are accessible from your Kubernetes container via a hostPath parameter in your pod .yaml file.

Example pod .yaml file:

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"

Best Practices

The data is local, so ensure that your application is resilient to having this data not be available. Local caching and processing are suitable workloads for this.

Current status

Kubernetes is planning to address stateful workloads better, including better support for local data, in a future version.

Monitor your resources on the go

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

Send feedback about...

Container Engine