A Beginner-Friendly Guide to Set Up Kubernetes Locally
When I first set out to set up a Kubernetes cluster on my own, I followed various online tutorials and blogs. Sounds easy, right? Except for one massive roadblock: setting up MetalLB. Most of the YouTube videos and guides I found assumed you’d be deploying your cluster on a cloud platform, where a load balancer is already baked in. But I was trying to set up a home lab on an old Lenovo T40 laptop — no cloud infrastructure, no fancy hardware, just what I had lying around.
If you’re anything like me, chances are your home lab is also built on a budget. Maybe you’re using some leftover hardware, or maybe you’ve found a ridiculously affordable VPC provider (I highly recommend checking out Webtropia for low-cost options). Either way, you probably don’t have access to dedicated load balancers or advanced networking devices.
After countless hours of tweaking and scouring the internet for a comprehensive guide to setting up MetalLB with basic hardware, I hit a wall. So, I got creative. In this blog, I’ll share how I managed to set up a Kubernetes cluster using k3s, kube-vip, and MetalLB — all on budget-friendly resources. Let’s dive in!
Tools You’ll Need
To replicate this setup, here’s what you’ll need:
k3s: A lightweight Kubernetes distribution.
k9s: A terminal-based tool for monitoring and administering your cluster.
kube-vip: For handling VIPs (Virtual IPs).
MetalLB: To act as a load balancer for your Kubernetes cluster.
Optional but handy tools:
- A GUI-based tool like ArgoCD for managing workloads after installation.
Step-by-Step Guide to Setting Up Your Cluster
1. Provision Your VPCs
For this guide, I used three VPCs as the control plane for my Kubernetes cluster. You can extend this setup to add worker nodes as needed. If you don’t have physical hardware, consider using affordable VPC providers like Webtropia. The key is to have at least three nodes to achieve high availability.
2. Install k3s
On each of your nodes, install k3s:
curl -sfL https://get.k3s.io | sh -
For the master node, initialize the cluster and note down the token:
k3s server --cluster-init
For the additional nodes, join them to the cluster using the token:
k3s agent --server https://<master-node-ip>:6443 --token <your-token>
3. Configure MetalLB
MetalLB is a load balancer implementation for bare-metal Kubernetes clusters. Here’s how to set it up:
-
Install MetalLB:
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/main/manifests/metallb.yaml
-
Create a ConfigMap: Configure an IP address pool that MetalLB can use:
apiVersion: v1 kind: ConfigMap metadata: namespace: metallb-system name: config data: config: | address-pools: - name: default protocol: layer2 addresses: - 192.168.1.240-192.168.1.250
Replace the
addresses
range with a range suitable for your network.
4. Set Up kube-vip
kube-vip simplifies high availability for your Kubernetes control plane. Install kube-vip as a DaemonSet:
kubectl apply -f https://kube-vip.io/manifests/kube-vip-ds.yaml
Then, configure kube-vip to manage the virtual IP for your control plane. For example:
kube-vip install \
--vip 192.168.1.100 \
--interface eth0 \
--controlplane \
--arp
5. Test Your Setup
Once everything is up and running, test your cluster by deploying a sample application:
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=LoadBalancer
Access the application through the load balancer’s IP address.
For detailed instructions, refer to the Kubernetes Documentation.
When Do You Actually Need Kubernetes?
Let’s be honest: Kubernetes isn’t for everyone. If you’re building a simple application or a prototype, Kubernetes is overkill. A few Docker containers or a lightweight VM setup might be all you need.
Kubernetes becomes valuable when scaling is a challenge. If your application has unpredictable spikes in usage or requires automatic scaling, Kubernetes’ orchestration capabilities are unmatched. But for predictable workloads, Docker Compose or Portainer might be a better choice.
Conclusion
Setting up Kubernetes on a budget is entirely possible, even without cloud infrastructure or expensive hardware. With tools like k3s, MetalLB, and kube-vip, you can create a fully functional cluster on old hardware or low-cost VPCs. While it might take some effort, the experience is incredibly rewarding and a great way to level up your skills.
Have you found better solutions or hit roadblocks in your own Kubernetes setup journey? Share them in the comments below — I’d love to hear your stories!
Resources That Helped Me (and Where I Got Stuck)
-
Some Helpful YouTube Videos:
Top comments (0)