The purpose of this repo is to provide a simple way to launch a multi-node Kubernetes cluster for local development, both in Windows with WSL2 & natively on Linux
- k3s-vagrant-virtualbox
- Index
- Infrastructure configuration
- Windows considerations
- Launch
- Kubeconfig
- Tech stack
-
Clone this repo
-
Edit
vars/infra.yml
as prefered
---
# VMs hostnames (FQDN) - Example: pier.terrapin.ch
master_server: master.juna
worker_node_1: worker1.juna
worker_node_2: worker2.juna
# IP addreses
master_server_ip: "10.0.1.10"
worker_node_1_ip: "10.0.1.20"
worker_node_2_ip: "10.0.1.30"
# Disk sizes
master_server_disk: "100GB"
worker_node_1_disk: "80GB"
worker_node_2_disk: "80GB"
# Hardware - RAM specified in MB
master_server_cpus: "4"
master_server_ram: 8192
worker_nodes_cpus: "2"
worker_nodes_ram: 4096
# OS - Ubuntu 24.04
vagrant_box: "bento/ubuntu-24.04"
# VirtualBox for Ubuntu 22.04 - https://www.virtualbox.org/wiki/Linux_Downloads
# Will be installed on the host that launches the playbooks (localhost by default)
vbox_ubuntu: "https://download.virtualbox.org/virtualbox/7.0.20/virtualbox-7.0_7.0.20-163906~Ubuntu~noble_amd64.deb"
- Install on your windows machine: Vagrant, VirtualBox & WSL2
- Create Ubuntu distribution:
wsl --install -d ubuntu
- Convert distribution to use WSL2:
wsl --set-version ubuntu 2
- Enter the machine
wsl -d Ubuntu
- Install Ansible
python3 -m pip install ansible
Inside WSL
ansible-playbook deploy_infra_windows.yml
Outside WSL
vagrant up
Inside WSL - After vagrant up finishes
ansible-playbook setup_k3s.yml
ansible-playbook deploy_infra.yml
ansible-playbook setup_k3s.yml
Your kubeconfig file will be in ~/.kube/k3s.yaml to use it you can set the KUBECONFIG environment variable with this command
export KUBECONFIG="~/.kube/k3s.yaml"
Verify you have access to the cluster
kubectl get nodes
And you're all set
Logo | Name | Description |
---|---|---|
K3s | Lightweight Kubernetes | |
Ansible | Automate VM provisioning and configuration | |
Vagrant | Automate VM creation in Virtualbox | |
VirtualBox | Virtualization | |
WSL2 | Windows Subsystem for Linux | |
Ubuntu Server | Base OS for VMs |