Go to file
Nicholas Malcolm df67c61ba5 Add HA option, change to yaml inventory, cleanup
- HA option for multiple server nodes using embedded etcd
- Switch to yaml inventory file for easier editing and combining vars
- Update to full ansible module names
- Change master/node names to server/agent
- Cleanup small linting errors
- Add reboot playbook which staggers reboot to keep HA cluster up
- Move playbooks to playbook directory

Signed-off-by: Derek Nola <derek.nola@suse.com>
2023-11-08 10:23:56 -08:00
.github/workflows Bump GH actions 2023-11-07 14:00:07 -08:00
collections Add requirements.yml 2022-01-30 21:04:06 +01:00
playbook Add HA option, change to yaml inventory, cleanup 2023-11-08 10:23:56 -08:00
roles Add HA option, change to yaml inventory, cleanup 2023-11-08 10:23:56 -08:00
.gitignore Comply with ansible-lint 2023-11-07 14:00:07 -08:00
.yamllint Fixes #3: Fix linting issues, add ansible-lint and yamllint configuration. 2020-05-12 16:00:32 -05:00
LICENSE Fixes #11: Add Apache 2.0 LICENSE file. 2020-05-12 15:29:41 -05:00
README.md Add HA option, change to yaml inventory, cleanup 2023-11-08 10:23:56 -08:00
ansible.cfg Add HA option, change to yaml inventory, cleanup 2023-11-08 10:23:56 -08:00
inventory-sample.yml Add HA option, change to yaml inventory, cleanup 2023-11-08 10:23:56 -08:00

README.md

Build a Kubernetes cluster using k3s via Ansible

Author: https://github.com/itwars

K3s Ansible Playbook

Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running:

  • Debian
  • Ubuntu
  • CentOS

on processor architecture:

  • x64
  • arm64
  • armhf

System requirements

Deployment environment must have Ansible 2.4.0+ Master and nodes must have passwordless SSH access

Usage

First copy the sample inventory to inventory.yml.

cp inventory-sample.yml inventory.yml

Second edit the inventory file to match your cluster setup. For example:

k3s_cluster:
  children:
    server:
      hosts:
        192.16.35.11
    agent:
      hosts:
        192.16.35.12
        192.16.35.13

If needed, you can also edit vars section at the bottom to match your environment.

If multiple hosts are in the server group the playbook will automatically setup k3s in HA mode with embedded etcd. An odd number of server nodes is recommended (3,5,7). Read the offical documentation below for more information and options. https://rancher.com/docs/k3s/latest/en/installation/ha-embedded/ Using a loadbalancer or VIP as the API endpoint is preferred but not covered here.

Start provisioning of the cluster using the following command:

ansible-playbook playbook/site.yml -i inventory.yml

Kubeconfig

To get access to your Kubernetes cluster just

scp debian@server_ip:~/.kube/config ~/.kube/config