Hey folks! So you want to dive into the world of DevOps? 🚀 Been meaning to write about this for a while because, honestly, setting up a home lab changed my life. Seriously. If you're like me, you’ve probably wondered how to practice DevOps skills without having access to an enterprise-level setup. Don’t worry, I've got you covered.
When I first started exploring DevOps, I struggled for months trying to cobble together what I thought would be the perfect setup. Spoiler: It took me 3 hours to debug what was a typo. 🤦♂️ But through tons of trial and error, I finally found a setup that worked for me, and today I’m here to share that journey with you!
Getting Started: The Basics
First things first, you need a decent computer with at least 16GB of RAM and a modern processor. Virtualization is going to be your best friend here, so make sure your machine can handle it. I use VirtualBox—it's free and works like a charm.
Next, install Vagrant. Trust me, this tool saved my project. It helps in managing virtual environments effortlessly. vagrant init will be your starting point, creating a Vagrantfile where you can specify your environment setup.
Kickstarting Your Enviro with a Simple Script
Here's the code that finally worked for me:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
endCopy-paste this, trust me 😉. It sets up a basic Ubuntu environment with port forwarding, so you can access your web server through localhost:8080.
Installing DevOps Tools
Alright, now that your environment is up and running, let's fill it with the good stuff. You'll need to install Git, Docker, and Jenkins. Spent hours figuring out the correct order. Seriously, don't make my mistake—here's the correct way:
sudo apt update
sudo apt install git -y
sudo apt install docker.io -y
# Install Jenkins
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -yThis snippet saved my project, hope it helps you too!
Networking Nirvana
One more thing before I forget—networking! I still remember the frustration of docker containers not being able to communicate. To fix it, set up a bridge network in Docker. docker network create --driver bridge my_network did wonders for me.
Troubleshooting: When Things Go South
Pro tip from someone who's been there: If Jenkins isn't starting, check /var/log/jenkins/jenkins.log. Often it's just a port conflict or Java memory allocation issue.
Conclusion: Build and Expand
I'm not an expert, but here's what worked for me. Keep building and expanding upon this setup. You can add Kubernetes (K8s) once you're comfy with Docker. Btw, I wrote about starting with Kubernetes last week - check it out!
Try this out and let me know how it goes! Drop a comment if you get stuck anywhere. I'll update this post if I find something better. 😊