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.
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:
Through Cluster Manifest: Add the following snippet to your cluster manifest when creating the cluster:
copyspec:...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.
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:
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.
copyspec:...addOns:localPathStorage: {}...
Kubernetes
in the left sidebar, and click on the cluster you wish to configure.Add-ons
, find the Local Path Storage
add-on in the list, and toggle it on.It is now possible to create Pods backed by hostPath
and local
volumes.
Create the following StatefulSet in your Managed Kubernetes cluster. For guidance on accessing your cluster, refer to the documentation page of your provider.
copy---apiVersion: v1kind: Servicemetadata:name: nginx-localpathlabels:app: nginx-localpathspec:ports:- port: 80name: webtype: LoadBalancerselector:app: nginx-localpath---apiVersion: apps/v1kind: StatefulSetmetadata:name: nginx-localpathlabels:app: nginx-localpathspec:serviceName: "nginx-localpath"selector:matchLabels:app: nginx-localpathreplicas: 1template:metadata:labels:app: nginx-localpathspec:containers:- name: nginx-localpathimage: registry.k8s.io/nginx-slim:0.8ports:- containerPort: 80name: webvolumeMounts:- name: www-localpathmountPath: /usr/share/nginx/htmlvolumeClaimTemplates:- metadata:name: www-localpathspec:accessModes: ["ReadWriteOnce"]storageClassName: local-pathresources:requests:storage: 1Gi