https://github.com/onedr0p/k3s-homeops-ansible
Bootstrap a k3s cluster on top of Ubuntu 20.04
https://github.com/onedr0p/k3s-homeops-ansible
ansible git gitops k3s kubernetes vagrant virtualbox
Last synced: 7 months ago
JSON representation
Bootstrap a k3s cluster on top of Ubuntu 20.04
- Host: GitHub
- URL: https://github.com/onedr0p/k3s-homeops-ansible
- Owner: onedr0p
- Archived: true
- Created: 2020-02-14T17:28:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-12T19:52:54.000Z (about 5 years ago)
- Last Synced: 2024-08-01T18:29:29.338Z (over 1 year ago)
- Topics: ansible, git, gitops, k3s, kubernetes, vagrant, virtualbox
- Language: HTML
- Homepage:
- Size: 628 KB
- Stars: 54
- Watchers: 10
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# k3s-homeops-ansible
This is an opinionated way to provision Ubuntu 20.04 and install k3s on top.
## Prerequisites
There's a couple things that will need to be done before you get starting running with Ansible.
1) Install Ansible >= 2.10.0 on your local machine
2) Install a supported OS on each of your nodes
3) Set static IP for each node on the OS or in your router (you can use the IP assigned via DHCP, but it's not recommended)
4) Copy your local public ssh key with `ssh-copy-id` to each node
5) _Optional_ review playbooks and roles to understand what these Ansible script will do
After that we're ready to continue with Ansible...
## Ansible
Get started by cloning this repository and copying the hosts and config into a new directory.
```bash
# clone this repo
git clone https://github.com/onedr0p/k3s-homeops-ansible
# change into the directory
cd k3s-homeops-ansible
# copy the hosts and config to a new folder
cp -r ./inventory/local ./inventory/custom
```
### Update the Ansible config files
**Note:** This project uses [PyratLabs/ansible-role-k3s](https://github.com/PyratLabs/ansible-role-k3s) for installing k3s. Configuration options can be viewed in their README.
After you have copied over the configuration files you will need to update the configuration in the files:
- `./inventory/custom/hosts.yml`: Host definitions
- `./inventory/custom/host_vars/*.yml`: Host IP and host level variables
- `./inventory/custom/group_vars/*.yml`: Global variables for all hosts
Each file it carefully documented.
### Get Ansible dependencies
```bash
ansible-galaxy install -r requirements.yml
```
### Run the playbooks
```bash
# This playbook will prepare your nodes for Kubernetes
ansible-playbook -i ./inventory/custom/hosts.yml ./playbooks/os-build.yml
# This playbook will install k3s
ansible-playbook -i ./inventory/custom/hosts.yml ./playbooks/cluster-build.yml
```
### Verify the cluster is up and running
```bash
kubectl --kubeconfig ./kubeconfig get nodes -o wide
```