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