diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2022-06-21 21:39:04 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2022-06-21 21:43:28 +0200 |
commit | 93ad4d03b9d87d6177514de27bb94d9230da82e6 (patch) | |
tree | 89da96ae3a43b34ec0db13f57a657c099e24a15d /content/posts | |
parent | acf5f44cba664debef95e1275dd26c5679e6e357 (diff) | |
download | gabrielgio.me-93ad4d03b9d87d6177514de27bb94d9230da82e6.tar.gz gabrielgio.me-93ad4d03b9d87d6177514de27bb94d9230da82e6.tar.bz2 gabrielgio.me-93ad4d03b9d87d6177514de27bb94d9230da82e6.zip |
ref: Move from orgmode to markdown
I'll never ever again move away from markdown.
fix: Move to http
... until I add a certificate
Diffstat (limited to 'content/posts')
-rw-r--r-- | content/posts/2019-03-03-welcome-to-my-blog.md | 14 | ||||
-rw-r--r-- | content/posts/2019-03-03-welcome-to-my-blog.org | 12 | ||||
-rw-r--r-- | content/posts/2019-03-07-ansible-part-1.md | 104 | ||||
-rw-r--r-- | content/posts/2019-03-07-ansible-part-1.org | 99 | ||||
-rw-r--r-- | content/posts/2019-04-22-ansible-part-2.md | 79 | ||||
-rw-r--r-- | content/posts/2019-04-22-ansible-part-2.org | 75 | ||||
-rw-r--r-- | content/posts/2019-11-16-compiling-emacs.md | 40 | ||||
-rw-r--r-- | content/posts/2020-07-13-k8s.md | 79 | ||||
-rw-r--r-- | content/posts/2020-07-14-fritzbox.md | 16 | ||||
-rw-r--r-- | content/posts/2020-08-22-genpass.md | 39 | ||||
-rw-r--r-- | content/posts/2020-12-28-k8s-private-registry.md | 56 | ||||
-rw-r--r-- | content/posts/2021-12-26-nfs-k3s.md | 62 |
12 files changed, 489 insertions, 186 deletions
diff --git a/content/posts/2019-03-03-welcome-to-my-blog.md b/content/posts/2019-03-03-welcome-to-my-blog.md new file mode 100644 index 0000000..01aeff3 --- /dev/null +++ b/content/posts/2019-03-03-welcome-to-my-blog.md @@ -0,0 +1,14 @@ ++++ +title = "Welcome to my blog" +date = 2019-03-03 +lastmod = 2020-07-12 ++++ + +On this blog, I\'ll be posting some personal projects that I\'m working +on or just logging stuff that I don\'t want to forget. + +*Disclaimer*: English it\'s not my native language so if you find +something that you don\'t understand I\'d love you to open an +[issue](https://gitlab.com/gabrielgio/homestation/-/issuess), or if you +have something to add open a +[MR](phttps://gitlab.com/gabrielgio/homestation/-/merge_requests) diff --git a/content/posts/2019-03-03-welcome-to-my-blog.org b/content/posts/2019-03-03-welcome-to-my-blog.org deleted file mode 100644 index 889131d..0000000 --- a/content/posts/2019-03-03-welcome-to-my-blog.org +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Welcome to my blog" -date: 2019-03-03 -lastmod: 2020-07-12 ---- - -On this blog, I'll be posting some personal projects that I'm working on or just -logging stuff that I don't want to forget. - -/Disclaimer/: English it's not my native language so if you find something that -you don't understand I'd love you to open an [[https://gitlab.com/gabrielgio/homestation/-/issuess][issue]], or if you have something to -add open a [[phttps://gitlab.com/gabrielgio/homestation/-/merge_requests][MR]] diff --git a/content/posts/2019-03-07-ansible-part-1.md b/content/posts/2019-03-07-ansible-part-1.md new file mode 100644 index 0000000..2746afc --- /dev/null +++ b/content/posts/2019-03-07-ansible-part-1.md @@ -0,0 +1,104 @@ +--- +layout: post +title: "Automating setup with ansible-pull part-1" +date: 2019-03-07 +lastmod: 2020-07-12 +tags: ['ansible','ansible-pull', 'linux', 'fedora'] +--- + +Every time that I do a clean install on my machine it takes a few hours till I +get to point where I was before formatting it, install all packages, select +themes, icons, fonts, install IDEs, extensions and so on. After doing it a few +times I came to the conclusion that I would save time by spending time +automating this chore, and as a result, I could toy a little more with my +system and not worry about spending a weekend re-installing everything (which +have happened more time that I\'d like to remember). + +\<!--more--> + +So after a few attempts using python and bash I ended with many files and keep +everything organized and concise turned out to be more tedious than the setup +itself. So there comes [Ansible](https://www.ansible.com/). It is an +enterprise-graded software used to automate tasks. It has A LOT OF features and +it can be really helpful if you\'re a sysadmin but for now we\'re going to +focus on [Ansible +Pull](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#ansible-pull) +and +[Playbooks](https://docs.ansible.com/ansible/latest/user_guide/playbooks.html). +As better described: + +> \[Ansible-Pull\] is used to up a remote copy of ansible on each +> managed node, each set to run via cron and update playbook source via +> a source repository. This inverts the default push architecture of +> Ansible into a pull architecture, which has near-limitless scaling +> potential. +> +> Playbooks are Ansible's configuration, deployment, and orchestration +> language. They can describe a policy you want your remote systems to +> enforce, or a set of steps in a general IT process. +> +> [source](https://docs.ansible.com/ansible/latest/cli/ansible-pull.html) + +The goal is to pull and run a playbook remotely using a git repository. +The playbook will describe the tasks needed to setup our machine from +scratch. + +But first lets toy a bit a with playbooks locally with `ansible-playbook`, to +do so we need to add `localhost` to ansible's hosts list. Add it to + `/etc/ansible/hosts`: + +``` service +[all] +localhost +``` + +As an experiment we\'re going to write a asks to install vim. Currently, I\'m +using [Fedora](https://getfedora.org/) thus we going to use [dnf +modeule](https://docs.ansible.com/ansible/latest/modules/dnf_module.html) to +install packages, but if you\'re using another distribution look for a +equivalent module like [apt +module](https://docs.ansible.com/ansible/latest/modules/apt_module.html) for +[Ubuntu](https://ubuntu.com/). + +The playbook to install is quite straightforward: + +``` yaml +# main.yaml +- hosts: all + tasks: + - name: install vim + dnf: + name: vim + state: latest +``` + +`hosts:` is required and it has to match our hosts otherwise the +playbook won\'t run. + +`tasks:` is the list of tasks that the playbook will perform, in this +case will be `dnf install vim`. + +To run a playbook use the command `ansible-playbook` commando to run +`main.yml` direct from disk, do to so just run the following command: + +``` bash +sudo ansible-playbook --connection=local main.yml +``` + +After a few seconds, vim will be installed on your machine. + +``` +PLAY [all] ************************************************************* + +TASK [Gathering Facts] ************************************************* +ok: [localhost] + +TASK [install vim] ***************************************************** +ok: [localhost] + +PLAY RECAP ************************************************************* +localhost : ok=2 changed=0 unreachable=0 failed=0 +``` + +This is the first step, next part we shall create a more complex +playbook and setup repository to run it remotely using `ansible-pull`. diff --git a/content/posts/2019-03-07-ansible-part-1.org b/content/posts/2019-03-07-ansible-part-1.org deleted file mode 100644 index c8782e9..0000000 --- a/content/posts/2019-03-07-ansible-part-1.org +++ /dev/null @@ -1,99 +0,0 @@ ---- -layout: post -title: "Automating setup with ansible-pull part-1" -date: 2019-03-07 -lastmod: 2020-07-12 -tags: ['ansible', 'ansible-pull', 'linux', 'fedora'] ---- - -Every time that I do a clean install on my machine it takes a few hours till I -get to point where I was before formatting it, install all packages, select -themes, icons, fonts, install IDEs, extensions and so on. After doing it a few -times I came to the conclusion that I would save time by spending time automating this chore, and -as a result, I could tinker a little more with my system and not worry about -spending a weekend re-installing everything (which have happened more time that -I'd like to remember). - -<!--more--> - -So after a few attempts using python and bash I ended with many files and -keep everything organized and concise turned out to be more tedious than the -setup itself. So there comes [[https://www.ansible.com/][Ansible]]. It is an enterprise-graded software used -to automate tasks. It has A LOT OF features and it can be really helpful if -you're a sysadmin but for now we're going to focus on [[https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#ansible-pull][Ansible Pull]] and -[[https://docs.ansible.com/ansible/latest/user_guide/playbooks.html][Playbooks]]. As better described: - -#+BEGIN_QUOTE -[Ansible-Pull] is used to up a remote copy of ansible on each managed node, each -set to run via cron and update playbook source via a source repository. This -inverts the default push architecture of Ansible into a pull architecture, which -has near-limitless scaling potential. - -Playbooks are Ansible’s configuration, deployment, and orchestration language. -They can describe a policy you want your remote systems to enforce, or a set of -steps in a general IT process. - -[[https://docs.ansible.com/ansible/latest/cli/ansible-pull.html][source]] -#+END_QUOTE - -The goal is to pull and run a playbook remotely using a git repository. The -playbook will describe the tasks needed to setup our machine from scratch. - -But first lets tinker a bit a with playbooks locally with ~ansible-playbook~, to -do so we need to add ~localhost~ to ansible's hosts list. Add it to -~/etc/ansible/hosts~: - -#+BEGIN_SRC service -[all] -localhost -#+END_SRC - -As an experiment we're going to write a asks to install vim. Currently, I'm using -[[https://getfedora.org/][Fedora]] thus we going to use [[https://docs.ansible.com/ansible/latest/modules/dnf_module.html][dnf modeule]] to install packages, but if you're using -another distribution look for a equivalent module like [[https://docs.ansible.com/ansible/latest/modules/apt_module.html][apt module]] for [[https://ubuntu.com/][Ubuntu]]. - -The playbook to install is quite simple: - -#+BEGIN_SRC yaml -# main.yaml -- hosts: all - tasks: - - name: install vim - dnf: - name: vim - state: latest -#+END_SRC - -~hosts:~ is required and it has to match our hosts otherwise the playbook won't -run. - -~tasks:~ is the list of tasks that the playbook will perform, in this case will -be ~dnf install vim~. - -To run a playbook use the command ~ansible-playbook~ commando to run -~main.yml~ direct from disk, do to so just run the following command: - -#+BEGIN_SRC bash -sudo ansible-playbook --connection=local main.yml -#+END_SRC - - -After a few seconds, vim will be installed on your machine. - -#+BEGIN_SRC -PLAY [all] ************************************************************* - -TASK [Gathering Facts] ************************************************* -ok: [localhost] - -TASK [install vim] ***************************************************** -ok: [localhost] - -PLAY RECAP ************************************************************* -localhost : ok=2 changed=0 unreachable=0 failed=0 -#+END_SRC - - -This is the first step, next part we shall create a more complex playbook and -setup repository to run it remotely using ~ansible-pull~. - diff --git a/content/posts/2019-04-22-ansible-part-2.md b/content/posts/2019-04-22-ansible-part-2.md new file mode 100644 index 0000000..e50005e --- /dev/null +++ b/content/posts/2019-04-22-ansible-part-2.md @@ -0,0 +1,79 @@ +--- +title: "Automating desktop setup with ansible-pull part-2" +date: 2019-04-22 +lastmod: 2020-07-12 +tags: ['ansible', 'ansible-pull', 'linux', 'fedora'] +--- + +Now we\'re going to setup ansible to work with a git repository. The process is +quite similar to `ansible-playbook`, the only difference is that the source for +the playbook will be a remote repository and not a local file. Following the +previous example we\'ll get vim setup automated. + +Create a git repository wherever you see fit, +[gitlab](https://about.gitlab.com/) and [github](https://github.com/) offer +free repositories. For this task we need to add only two file: one for the +`yml` file describing the tasks and the `.vimrc` file. + +In the `.vimrc` add your own configuration, you can see mine [over +here](https://gitlab.com/gabrielgio/homestation/-/blob/debcf3458df511aef9f7dca0cb73f6cf6baddd5d/.vimrc), +it is pretty small as I don\'t use it but for small text editing (like this +post) so you can start with that if you don\'t have one. + +The `yml` file will have two tasks, one is to install vim, just like we +did in the part 1. + +``` yaml +# main.yml +--- +- name: install vim + dnf: + name: vim + state: latest +``` + +To copy `.vimrc` file to your `$HOME` we going to use [copy +module](https://docs.ansible.com/ansible/latest/modules/copy_module.html): + +``` yaml +# main.yml +--- +- name: copy vimrc file + copy: + src: config/.vimrc + dest: ~/ + mode: 0644 +``` + +After we\'ve added those two files to repository you will have be something +[like +this](https://gitlab.com/gabrielgio/homestation/-/tree/debcf3458df511aef9f7dca0cb73f6cf6baddd5d). + +And now we just need to run `ansible-pull` command + +``` shell +# you may need run it as a sudo +ansible-pull -U $YOUR_REPO -i all main.yml +``` + +Params: + +- **`-i`** is a list of hosts. +- **`-U`** is the git repository URL. + +Remember `man` is your best friend, take a look at `man ansible-pull` to +know more about its parameters. + +The best part you can quickly test and see the result by running my +sample: + +``` shell +ansible-pull -U https://gitlab.com/gabrielgio/homestation.git -C debcf3458df511aef9f7dca0cb73f6cf6baddd5d -i all main.yml +``` + +The idea here is to keep your repository as a source of truth when comes to +configuration, you can add `ansible-pull` to a CRON tab, so you just need to +push something to your repository and after a few minutes not only your machine +but all the machines that have it setup will run the playbooks. You can use +this method as a straightforward way to install software, update machines or +even distribute tooling company-wise. diff --git a/content/posts/2019-04-22-ansible-part-2.org b/content/posts/2019-04-22-ansible-part-2.org deleted file mode 100644 index cea1161..0000000 --- a/content/posts/2019-04-22-ansible-part-2.org +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Automating desktop setup with ansible-pull part-2" -date: 2019-04-22 -lastmod: 2020-07-12 -tags: ['ansible', 'ansible-pull', 'linux', 'fedora'] ---- - -[[{{< ref "2019-03-07-ansible-part-1.org " >}}][See part 1]] - -Now we're going to setup ansible to work with a git repository. The process is -quite similar to ~ansible-playbook~, the only difference is that the source for -the playbook will be a remote repository and not a local file. Following the -previous example we'll get vim setup automated. - -Create a git repository wherever you see fit, [[https://about.gitlab.com/][gitlab]] and [[https://github.com/][github]] offer free -repositories. For this task we need to add only two file: one for the -~yml~ file describing the tasks and the ~.vimrc~ file. - - -In the ~.vimrc~ add your own configuration, you can see mine [[https://gitlab.com/gabrielgio/homestation/-/blob/debcf3458df511aef9f7dca0cb73f6cf6baddd5d/.vimrc][over here]], it is -pretty simple as I don't use it but for simple text editing (like this post) so -you can start with that if you don't have one. - -The ~yml~ file will have two tasks, one is to install vim, just like we did in -the part 1. - -#+BEGIN_SRC yaml -# main.yml ---- -- name: install vim - dnf: - name: vim - state: latest -#+END_SRC - -To copy ~.vimrc~ file to your ~$HOME~ we going to use [[https://docs.ansible.com/ansible/latest/modules/copy_module.html][copy module]]: - -#+BEGIN_SRC yaml -# main.yml ---- -- name: copy vimrc file - copy: - src: config/.vimrc - dest: ~/ - mode: 0644 -#+END_SRC - -After we've added those two files to repository you will have be something [[https://gitlab.com/gabrielgio/homestation/-/tree/debcf3458df511aef9f7dca0cb73f6cf6baddd5d][like -this]]. - -And now we just need to run ~ansible-pull~ command - -#+BEGIN_SRC shell -# you may need run it as a sudo -ansible-pull -U $YOUR_REPO -i all main.yml -#+END_SRC - -Params: -- *~-i~* is a list of hosts. -- *~-U~* is the git repository URL. - -Remember ~man~ is your best friend, take a look at ~man ansible-pull~ to know -more about its parameters. - -The best part you can quickly test and see the result by running my sample: -#+BEGIN_SRC shell -ansible-pull -U https://gitlab.com/gabrielgio/homestation.git -C debcf3458df511aef9f7dca0cb73f6cf6baddd5d -i all main.yml -#+END_SRC - -The idea here is to keep your repository as a source of truth when comes to -configuration, you can add ~ansible-pull~ to a CRON tab, so you just need to push -something to your repository and after a few minutes not only your machine but -all the machines that have it setup will run the playbooks. You can use this -method as a simple way to install software, update machines or even distribute -tooling company-wise. diff --git a/content/posts/2019-11-16-compiling-emacs.md b/content/posts/2019-11-16-compiling-emacs.md new file mode 100644 index 0000000..6773344 --- /dev/null +++ b/content/posts/2019-11-16-compiling-emacs.md @@ -0,0 +1,40 @@ +--- +title: "Compiling emacs from source code on Fedora" +date: 2019-11-16 +lastmod: 2020-08-25 +tags: ['emacs', 'emacs27','linux', 'fedora'] +--- + +Compiling emacs from source and installing on fedora. + +# Installing Packages + +Install the following packages: + +```shell +sudo dnf install git autoconf make gcc texinfo \ + gnutls-devel giflib-devel ncurses-devel \ + libjpeg-turbo-devel giflib-devel gtk3-devel \ + libXpm-devel libtiff-devel libxml2-devel -y +``` + +# Cloning Repository + +Clone repository +[savannah.gnu.org](http://savannah.gnu.org/projects/emacs/): + + git clone -b master git://git.sv.gnu.org/emacs.git + +# Compiling + +Navigate to emacs folder (`cd emacs`) and run the following steps + +```shell +./autogen.sh +./configure +make -j$(nproc) +sudo make install +``` + +After verify version with `emacs --version`, it should be equal or +higher than `28.0.50`. diff --git a/content/posts/2020-07-13-k8s.md b/content/posts/2020-07-13-k8s.md new file mode 100644 index 0000000..8b706c1 --- /dev/null +++ b/content/posts/2020-07-13-k8s.md @@ -0,0 +1,79 @@ +--- +title: "Road to local k8s" +date: 2020-07-13 +tags: ['kubernetes', 'linux', 'fedora'] +--- + +# Goal + +The goal is to deploy kubernetes on my local networks, and keep everything as +reproducible as possible. + +# Stack + +I\'ll use Fedora Core OS, Matchbox and Terraform [^1], a match the requirements +for Tectonic [^2] + +## Steps + +- Network Setup DHCP/TFTP/DNS [^3] +- Matchbox [^4] +- PXE network boot environment +- Terraform Tectonic [^5] + +## Network Setup DHCP/TFTP/DNS + +First learning the basics again: + +- <https://linuxhint.com/install_dhcp_server_ubuntu/> +- <https://www.youtube.com/watch?v=XQ3T14SIlV4> + +To check open ports + +```shell +lsof -Pni | grep LISTEN +``` + +Run the provided [^6] image with `dnsmasq` and PXE toolkit + +``` {.bash org-language="sh"} +docker run --rm --cap-add=NET_ADMIN --net=host quay.io/coreos/dnsmasq \ + -d -q \ + --dhcp-range=192.168.1.3,192.168.1.254 \ + --enable-tftp --tftp-root=/var/lib/tftpboot \ + --dhcp-match=set:bios,option:client-arch,0 \ + --dhcp-boot=tag:bios,undionly.kpxe \ + --dhcp-match=set:efi32,option:client-arch,6 \ + --dhcp-boot=tag:efi32,ipxe.efi \ + --dhcp-match=set:efibc,option:client-arch,7 \ + --dhcp-boot=tag:efibc,ipxe.efi \ + --dhcp-match=set:efi64,option:client-arch,9 \ + --dhcp-boot=tag:efi64,ipxe.efi \ + --dhcp-userclass=set:ipxe,iPXE \ + --dhcp-boot=tag:ipxe,http://matchbox.example.com:8080/boot.ipxe \ + --address=/matchbox.example/192.168.1.2 \ + --log-queries \ + --log-dhcp +``` + +## Matchbox + +## PXE network boot environment + +## Terraform Tectonic + +------------------------------------------------------------------------ + +# Links + +[^1]: <https://coreos.com/tectonic/docs/latest/install/bare-metal/metal-terraform.html> + +[^2]: <https://coreos.com/tectonic/docs/latest/install/bare-metal/requirements.html> + +[^3]: <https://coreos.com/matchbox/docs/latest/network-setup.html> + +[^4]: <https://coreos.com/matchbox/docs/latest/deployment.html> + +[^5]: <https://coreos.com/tectonic/releases/> + +[^6]: <https://github.com/poseidon/matchbox/tree/v0.7.0/contrib/dnsmasq> diff --git a/content/posts/2020-07-14-fritzbox.md b/content/posts/2020-07-14-fritzbox.md new file mode 100644 index 0000000..bba7f4e --- /dev/null +++ b/content/posts/2020-07-14-fritzbox.md @@ -0,0 +1,16 @@ +--- +title: "Friz.box turned off DHCP" +date: 2020-07-14 +tags: ['fritz.box', 'DHCP'] +--- + +If you turned off your DHCP server follow these steps to connect to FritzBox +settings. + +- Set your computer IP to `169.254.1.2` and your mask to `255.255.0.0` +- Then go to `169.254.1.1`, login and re-enable the DHCP server. + +On gnome turn the wired connection off on again to apply the settings. + +Note: why in the hell does FritzBox 7490 require a land-line telephone to be +physically factory reset? diff --git a/content/posts/2020-08-22-genpass.md b/content/posts/2020-08-22-genpass.md new file mode 100644 index 0000000..3991a86 --- /dev/null +++ b/content/posts/2020-08-22-genpass.md @@ -0,0 +1,39 @@ +--- +title: "Moving from Github to Gitlab pages" +date: 2020-08-22 +tags: ['gitlab'] +--- + +This was quite fast, I had just to create a small Gitlab pipeline job and +publish to pages this is done by: + +```yml +image: clojure:lein-2.7.0 + +before_script: + - lein deps + +test: + script: + - lein test + +pages: + stage: deploy + script: + - lein package + artifacts: + paths: + - public + only: + - master +``` + +before_script +: will download all the dependencies with `lein deps`. + +test +: is self explanatory. + +pages +: will compile the cljs into js with `lein package` and publish it + into pages. diff --git a/content/posts/2020-12-28-k8s-private-registry.md b/content/posts/2020-12-28-k8s-private-registry.md new file mode 100644 index 0000000..6706da7 --- /dev/null +++ b/content/posts/2020-12-28-k8s-private-registry.md @@ -0,0 +1,56 @@ +--- +title: "K8S private gitlab registry using podman" +date: 2021-12-28 +tags: ['kubernetes', 'linux', 'podman', 'gitlab', 'k3s'] +--- + +This is based on [Log in to Docker +Hub](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/). +It is just a bit different to use podman + +First we should take a look at podman-login man page: + +``` bash +man podman login +``` + +It will give some valueable information like the location of auth.json +file. Now we can login using podman: + +``` bash +podman login registry.gitlab.com +``` + +Then check the `auth.json` file located at +`${XDG_RUNTIME_DIR}/containers/auth.json` (as described by the manual). + +``` bash +cat "${XDG_RUNTIME_DIR}/containers/auth.json" +``` + +It will print your auth config: + +``` json +{ + "auths": { + "registry.gitlab.com": { + "auth": "..." + } + } +} +``` + +Now copy that file over to the server and register it in k8s with the +following command: + +``` bash +kubectl create secret generic regcred \ + --from-file=.dockerconfigjson=auth.json \ + --type=kubernetes.io/dockerconfigjson +``` + +Once you have created you can list by `kubectl get secret`: +``` +NAME TYPE DATA AGE +regcred kubernetes.io/dockerconfigjson 1 53s +``` diff --git a/content/posts/2021-12-26-nfs-k3s.md b/content/posts/2021-12-26-nfs-k3s.md new file mode 100644 index 0000000..e9988c7 --- /dev/null +++ b/content/posts/2021-12-26-nfs-k3s.md @@ -0,0 +1,62 @@ +--- +title: "Enable NFS on K3S" +date: 2021-12-26 +tags: ['kubernetes', 'linux', 'helm', 'k3s'] +--- + +By default [K3S](https://k3s.io/) comes only with +[local-path](https://github.com/rancher/local-path-provisioner) storage +class, and if you are running with more than one node in your cluster +you may want to use a more \"distributed\" solution. For may case I +opted for NFS. + +To check the current storage class you can run: + +``` bash +k3s kubectl get storageclasses +``` + +And it will print something like: + + NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE + local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 154d + +To start adding First you need to install +[helm](https://github.com/helm/helm) on your server. To do so you may +run: + +``` bash +curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash +``` + +**Be careful when running scripts directly into bash always check the +source** **Sometimes is also recommended to do not pipe directly to +bash** + +Once it is installed we need to add the [NFS storage +classes](https://kubernetes.io/docs/concepts/storage/storage-classes/#nfs). +It has two providers, I have chose [NFS Subdir External +Provisioner](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner). + +Add the helm repo + +``` bash +helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/ +``` + +Then we need to actually install the provider + +``` bash +helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \ + --set nfs.server=x.x.x.x \ + --set nfs.path=/exported/path +``` + +Set the `nfs.server` and `nfs.path` accordingly with your setup. + +After that if we run `k3s kubectl get storageclasses` it will now print +another NFS provider: + + NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE + local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 154d + nfs-client cluster.local/nfs-subdir-external-provisioner Delete Immediate true 76m |