macroblog.rs @ 77281bfab6d35556f121b95980dc6dccd0243842

 1By default [K3S](https://k3s.io/) comes only with
 2[local-path](https://github.com/rancher/local-path-provisioner) storage
 3class, and if you are running with more than one node in your cluster
 4you may want to use a more \"distributed\" solution. For may case I
 5opted for NFS.
 6
 7To check the current storage class you can run:
 8
 9``` bash
10k3s kubectl get storageclasses
11```
12
13And it will print something like:
14
15    NAME                   PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
16    local-path (default)   rancher.io/local-path                           Delete          WaitForFirstConsumer   false                  154d
17
18To start adding First you need to install
19[helm](https://github.com/helm/helm) on your server. To do so you may
20run:
21
22``` bash
23curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
24```
25
26**Be careful when running scripts directly into bash always check the
27source** **Sometimes is also recommended to do not pipe directly to
28bash**
29
30Once it is installed we need to add the [NFS storage
31classes](https://kubernetes.io/docs/concepts/storage/storage-classes/#nfs).
32It has two providers, I have chose [NFS Subdir External
33Provisioner](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner).
34
35Add the helm repo
36
37``` bash
38helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
39```
40
41Then we need to actually install the provider
42
43``` bash
44helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
45    --set nfs.server=x.x.x.x \
46    --set nfs.path=/exported/path
47```
48
49Set the `nfs.server` and `nfs.path` accordingly with your setup.
50
51After that if we run `k3s kubectl get storageclasses` it will now print
52another NFS provider:
53
54    NAME                   PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
55    local-path (default)   rancher.io/local-path                           Delete          WaitForFirstConsumer   false                  154d
56    nfs-client             cluster.local/nfs-subdir-external-provisioner   Delete          Immediate              true                   76m