Thanks to visit codestin.com
Credit goes to github.com

Skip to content

e3palma/ansible-k3s-ha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible-k3s-ha

ansible-k3: Kubernetes Lighweight Cluster with Ansible automation

This playbook sets up a k3s cluster in High-Availability (HA) and installs Rancher and Longhorn.

How to use script

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

Playbook Details

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
  • 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

For more details see the roles README.md files.

Inventory details and example


[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

Playbook example

---
---
- 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published