Overview

The Local Path Storage add-on enables the Rancher Local Path Provisioner. This feature allows users to automatically create persistent volumes based on either hostPath or local storage on the node.

Before using this feature, be aware that Local Volumes have their own limitations. It’s important to familiarize yourself with hostPath and local volumes, including their purposes and limitations. For more information, refer to the Kubernetes Documentation.

Supported Providers

How to Enable

The Local Path Storage add-on can be enabled for your Kubernetes cluster either during the cluster creation process or at any time thereafter. The following sections outline the methods for enabling the add-on:

At Cluster Creation

  • Through Cluster Manifest: Add the following snippet to your cluster manifest when creating the cluster:

    YAML
    spec:
      ...
      addOns:
        localPathStorage: {}
      ...
    
  • Using the Console: If you’re creating the cluster through the console, navigate to Add-ons, find the Local Path Storage add-on in the list of available add-ons, and toggle it on.

After Cluster Creation

If the Local Path Storage add-on was not enabled during the cluster creation, you can still enable it using either of the following methods:

Using Manifest

To enable the Local Path Storage add-on after cluster creation, add the following to your cluster’s YAML manifest:

  • Direct Edit & Apply: Navigate to your cluster in the Console, and use the Edit & Apply option.

  • CLI Application: Apply the entire manifest using the cpln apply >_ command or through the cpln CLI.

    YAML
    spec:
      ...
      addOns:
        localPathStorage: {}
      ...
    

Using the UI

  1. Navigate to the Control Plane Console: Open Control Plane Console.
  2. Select Your Kubernetes Cluster: In the Control Plane Console, go to Kubernetes in the left sidebar, and click on the cluster you wish to configure.
  3. Activate the Dashboard: Choose Add-ons, find the Local Path Storage add-on in the list, and toggle it on.

Usage Instructions

It is now possible to create Pods backed by hostPath and local volumes.

Create a StatefulSet that uses a local volume for the storage of its pods

Create the following StatefulSet in your Managed Kubernetes cluster. For guidance on accessing your cluster, refer to the documentation page of your provider.

YAML
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-localpath
  labels:
    app: nginx-localpath
spec:
  ports:
    - port: 80
      name: web
  type: LoadBalancer
  selector:
    app: nginx-localpath
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx-localpath
  labels:
    app: nginx-localpath
spec:
  serviceName: 'nginx-localpath'
  selector:
    matchLabels:
      app: nginx-localpath
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-localpath
    spec:
      containers:
        - name: nginx-localpath
          image: registry.k8s.io/nginx-slim:0.8
          ports:
            - containerPort: 80
              name: web
          volumeMounts:
            - name: www-localpath
              mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
    - metadata:
        name: www-localpath
      spec:
        accessModes: ['ReadWriteOnce']
        storageClassName: local-path
        resources:
          requests:
            storage: 1Gi