This playbook sets up a k3s cluster in High-Availability (HA) and installs Rancher and Longhorn.
run ./play.sh
# when promoted for BECOME password enter password for local pc running script
# If Master and slave nodes are configured with passwordless sudo (insecure) remove the following lines from main.yml
vars:
ansible_sudo_pass: "{{ pass }}"
Credits and many thanks to
- Ansible-k3sup this play book originally started as a fork from Ansible-k3sup
- Rancher the creators of k3s,
- Longhorn maintained by Cloud-Native Computing Foundation,
- alexellis for k3sup,
- Kube-VIP,
- RobeDevOps for ansible-k3s
- itwars for the inspiring playbook
- JimsGarage for his video and tutorials. Playbook was developed based on his K3S script
This playbook consist of roles executing the following main functions:
- On master and slave systems
- When deploying to Raspbian
- Enables cgroups 'cpu' + 'memory' in /boot/cmdline.txt
- Disable the 'dphys-swapfile' service in systemd
- Optional playbook to clean and remove K3S
- When deploying to Raspbian
- Only on localhost
- Install k3sup setup script
- Then install k3sup binary
- Configure UFW and Firewalld with ports required by K3S if installed
- Create k3s cluster
- use Kube-VIP for loadbalancing
- Creates cluster in High-Availability (HA)
- Install Rancher
- Install Longhorn
- Install k3sup setup script
For more details see the roles README.md files.
[master]
master1 ansible_user=admin
[masters]
master2 ansible_user=admin
master3 ansible_user=admin
[slave]
slave1 ansible_user=admin
slave2 ansible_user=admin
slave3 ansible_user=admin
---
---
- hosts: k3s_cluster
become: yes
vars_files: inventory/group_vars/secret.yml
vars:
ansible_sudo_pass: "{{ pass }}"
roles:
- container_features
- dphys_swapfile
- hosts: localhost
roles:
- bootstrap_k3sup
- k3s_cluster
- hosts: k3s_cluster
become: yes
vars_files: inventory/group_vars/secret.yml
vars:
ansible_sudo_pass: "{{ pass }}"
roles:
- undosudo