Skip to content

Commit 0fb290e

Browse files
committed
Add tutorial of using local-path-provisioner
1 parent fc9d510 commit 0fb290e

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: "Using Local Path Provisioner"
3+
linkTitle: "Using Local Path Provisioner"
4+
weight: 1
5+
date: 2022-10-05
6+
description: >
7+
Using Local Path Provisioner
8+
---
9+
10+
## Overview
11+
12+
[Local Path Provisioner](https://github.com/rancher/local-path-provisioner), provides a way for the Kubernetes users to utilize the local storage in each node. It supports multi-node setups. This tutorial will show you how to setup local-path-prvisioner on two node minikube cluster.
13+
14+
## Prerequisites
15+
16+
- Minikube version higher than v1.27.0
17+
- kubectl
18+
19+
## Tutorial
20+
21+
- Start a cluster with 2 nodes:
22+
23+
```shell
24+
$ minikube start -n 2
25+
```
26+
27+
- Enable `storage-provisioner-rancher` addon:
28+
29+
```
30+
$ minikube addons enable storage-provisioner-rancher
31+
```
32+
33+
- You should be able to see Pod in the `local-path-storage` namespace:
34+
35+
```
36+
$ kubectl get pods -n local-path-storage
37+
NAME READY STATUS RESTARTS AGE
38+
local-path-provisioner-7f58b4649-hcbk9 1/1 Running 0 38s
39+
```
40+
41+
- The `local-path` StorageClass should be marked as `default`:
42+
43+
```
44+
$ kubectl get sc
45+
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
46+
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 107s
47+
standard k8s.io/minikube-hostpath Delete Immediate false 4m27s
48+
```
49+
50+
- The following `yaml` creates PVC and Pod that creates file with content on second node (minikube-m02):
51+
52+
```
53+
---
54+
apiVersion: v1
55+
kind: PersistentVolumeClaim
56+
metadata:
57+
name: test-pvc
58+
spec:
59+
accessModes:
60+
- ReadWriteOnce
61+
resources:
62+
requests:
63+
storage: 64Mi
64+
---
65+
apiVersion: v1
66+
kind: Pod
67+
metadata:
68+
name: test-local-path
69+
spec:
70+
restartPolicy: OnFailure
71+
nodeSelector:
72+
"kubernetes.io/hostname": "minikube-m02"
73+
containers:
74+
- name: busybox
75+
image: busybox:stable
76+
command: ["sh", "-c", "echo 'local-path-provisioner' > /test/file1"]
77+
volumeMounts:
78+
- name: data
79+
mountPath: /test
80+
volumes:
81+
- name: data
82+
persistentVolumeClaim:
83+
claimName: test-pvc
84+
```
85+
86+
```
87+
$ kubectl get pvc
88+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
89+
test-pvc Bound pvc-f07e253b-fea7-433a-b0ac-1bcea3f77076 64Mi RWO local-path 5m19s
90+
```
91+
92+
```
93+
$ kubectl get pods -o wide
94+
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
95+
test-local-path 0/1 Completed 0 5m19s 10.244.1.5 minikube-m02
96+
```
97+
98+
- On the second node we are able to see created file with content `local-path-provisioner`:
99+
100+
```
101+
$ minikube ssh -n minikube-m02 "cat /opt/local-path-provisioner/pvc-f07e253b-fea7-433a-b0ac-1bcea3f77076_default_test-pvc/file1"
102+
local-path-provisioner
103+
```

0 commit comments

Comments
 (0)