To deploy an app using our GitLab Server we need a Kubernetes cluster. In a Linux laptop a single kind command can create a cluster. That is a good option that you can use, in that case you can skip the rest of this post and continue with the app deployment in the next post (available soon).
But I have two beautiful Raspberry Pi 4 in which I have installed Ubuntu Server that is available for their arm64 (64 bits processor).
An excellent guide to set up servers is at blog.zachinachshon.com that explains in several posts each step needed to run a complete Kubernetes bare metal installation. You can follow the hole series or stop just when you get your Linux boxes running with password-less ssh log-in from your machine.
Then use Ansible and this Github scripts to create a k3s cluster. Just follow the instructions to modify the inventory file with your own IP’s and then run the ansible-playbook command in the readme and you’ll end up with a cluster.
Notes on how to read the downloaded files:
The inventory file (hosts.ini) is key to define the ‘groups’ of machines that are ‘k3s_cluster’ (all machines), or ‘master’ and ‘node’.
At the same folder level of the inventory file, we can read the ‘group_vars’ to be used on the groups defined above, those are mainly the version of k3s to install, and the user to log into the machines that are: k3s_version (v1.17.5+k3s1) and ansible_user (debian I changed that to ubuntu).
Note: There is also a reset.yml playbook file to erase the k3s installation.
The actions to execute from the roles directories are listed in the ‘site.yml‘ file:
Will enable IPv4 and IPv6ip. For systems with CentOS or RedHat SELinux will be disabled, the netfilter and iptables will be reloaded and path will now contain /usr/local/bin.
k3s will be downloaded for the apropiate processor: AMD, arm64 o arm32
In case it is a Raspberry some actions are needed: The vesrion is ‘registered’ and then runs actions in a subdirectory named prereq for: Default (no action), Ubuntu & CentOS (configure cgroup if it is not already in
cmdline.txt), Raspbian (iptables) and if needed the reboot.
Enable and configure k3s service in the master and node using the template files. In the master the token to associate the node to the cluster is written to a file then read and lastly kubectl is configured (.kube/config).
In the instructions we copy the config file to the PC so we can use kubectl commands to interact with the cluster.