This repository contains Ansible playbooks and configuration for setting up a Kubernetes cluster using Vagrant with libvirt provider. It creates a three-node cluster with one control plane and two worker nodes, all running on Debian 12.
The cluster consists of:
- 1 control plane node (2GB RAM, 2 CPUs)
- 2 worker nodes (2GB RAM, 2 CPUs each)
- Private network: 192.168.121.0/24
- Pod network: 10.244.0.0/16
./build-k8s-base-box.sh
This command will:
- Download the Debian 12 base box
- Install system updates and required packages
- Install containerd container runtime
- Install Kubernetes components (kubeadm, kubelet, kubectl)
- Package the resulting VM into a new Vagrant box named 'k8s-base'
vagrant up
This command will:
- Create three virtual machines using the k8s-base box
- Initialize the Kubernetes control plane on k8s-control
- Set up pod networking
- Generate join tokens for worker nodes
- Join worker nodes to the cluster
- Install Helm package manager on the control plane
The kubeconfig file is automatically configured on the control plane node. To access and verify the cluster:
-
SSH into the control plane:
vagrant ssh k8s-control
-
Verify cluster status:
# Check node status kubectl get nodes # View running system pods kubectl get pods -A
You should see three nodes (one control plane and two workers) in Ready state.
When you're done experimenting, you can destroy all VMs:
vagrant destroy -f
vagrant box remove k8s-base
rm -rf output-k8s-base
- Control plane: 192.168.121.10
- Worker 1: 192.168.121.11
- Worker 2: 192.168.121.12
See LICENSE file.