Ansible playbook to deploy K3s and the OSCAR platform
contains all the necessary files to deploy a K3s cluster
together with the OSCAR platform using Ansible.
This way, a minified Kubernetes distribution can be used to configure OSCAR on
IoT devices located at the Edge, such as
Raspberry PIs. Note that this
can also be applied to quickly spread the OSCAR platform on top of any machine
or already started cloud instance since the playbook is compatible with
GNU/Linux on ARM64 and AMD64 architectures.
In order to use the playbook, you must install the following components:
- Ansible, following this guide.
- OpenSSH, to remotely access the hosts to be configured.
Clone the folder
First of all, you must clone the OSCAR repo:
git clone https://github.com/grycap/oscar.git
And place into the
As Ansible is an agentless automation tool, you must configure the
~/.ssh/config file for granting access to the hosts to be configured via
the SSH protocol. This playbook will use the
Host field from SSH
configuration to set the hostnames of the nodes, so please take care of naming
Below you can find an example of a configuration file for four nodes, being
front the only one with a public IP, so it will be used as a proxy for
the SSH connection to the working nodes
option) via its internal network.
Configuration of the inventory file
Now, you have to edit the
hosts file and add the hosts to be configured.
Note that only one node must be set in the
[front] section, while one or
more nodes can be configured as working nodes of the cluster in the
section. For example, for the previous SSH configuration
hosts inventory file should look like this:
; Put here the frontend node as defined in .ssh/config (Host)
; Put here the working nodes (one per line) as defined in the .ssh/config (Host)
Setting up the playbook variables
You also need to set up some parameters for the configuration of the cluster
and OSCAR components, like OSCAR and MinIO credentials and DNS endpoints to
configure the Kubernetes Ingress and cert-manager
to securely expose the services. To do it, please edit the
and update the variables:
# K3s version to be installed
# Token to login in K3s and the Kubernetes Dashboard
# Password for OSCAR
# DNS name for the OSCAR Ingress and Kubernetes Dashboard (path "/dashboard/")
# Password for MinIO
# DNS name for the MinIO API Ingress
# DNS name for the MinIO Console Ingress
Installation of the required ansible roles
To install the required roles you only have to run:
ansible-galaxy install -r install_roles.yaml --force
--force argument ensures you have the latest version of the roles.
Running the playbook
Finally, with the following command the ansible playbook will be executed,
configuring the nodes set in the
hosts inventory file:
ansible-playbook -i hosts oscar-k3s.yaml