macroblog.rs @ b4472b41214eeeacce071df41bf0f782e1f16d6d

 1<section>
 2    <p>
 3        By default <a href="https://k3s.io/">K3S</a> comes only
 4        with <a href="https://github.com/rancher/local-path-provisioner">local-path</a>
 5        storage class, and if you are running with more than one node in your
 6        cluster you may want to use a more &ldquo;distributed&rdquo; solution.
 7        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
20        install <a href="https://github.com/helm/helm">helm</a> on your server.
21        To do so you may 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
27        source Sometimes is also recommended to do not pipe directly to bash
28    </p>
29    <p>
30        Once it is installed we need to add
31        the <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#nfs">NFS
32        storage classes</a>. It has two providers, I have
33        chose <a href="https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner">NFS
34        Subdir External Provisioner</a>.
35    </p>
36    <p>
37        Add the helm repo
38    </p>
39
40    <pre><code>helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/</code></pre>
41    <p>
42        Then we need to actually install the provider
43    </p>
44    <div class="org-src-container">
45<pre><code>helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner
46--set nfs.server=x.x.x.x
47--set nfs.path=/exported/path</code></pre>
48    </div>
49    <p>
50        Set the <code>nfs.server</code> and <code>nfs.path</code> accordingly
51        with your setup.
52    </p>
53    <p>
54        After that if we run <code>k3s kubectl get storageclasses</code> it will
55        now print another NFS provider:
56    </p>
57
58    <pre><code>NAME                   PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
59local-path (default)   rancher.io/local-path                           Delete          WaitForFirstConsumer   false                  154d
60nfs-client             cluster.local/nfs-subdir-external-provisioner   Delete          Immediate              true                   76m</code></pre>
61</section>