How I built a versatile and repeatable Homelab with Terraform — HomeLab Part 2

This is the second part of the HomeLab series, where I’m creating an on-premise (my Home) setup for all my personal needs. Checkout the YouTube Video for Part 1 here or you can read it here.

The HomeLab Setup

Node Requirements

Installing Docker

# install docker
$ sudo install

Some troubleshooting required

$ cat /etc/docker/daemon.json 
"exec-opts": [
$ sudo apt install linux-modules-extra-raspi socat

k3s molecule

$ sudo apt install socat
terraform {
required_version = ">=1.3.0"

# backend "http" { }
cat inputs.tfvars
servers = [ {
host = ""
private_key = "~/.ssh/id_rsa"
user = "root"
} ]
# Make sure you're in the right molecule
$ cd molecules/k3s

$ terraform apply -var-file=inputs.tfvars
$ sudo journalctl -u k3s.service -r | less

$ sudo journalctl --flush --vacuum-size=1B

Enrich the Server (cluster-resources molecule)

cd molecules/cluster-resources
$ terraform apply -var-file=local.inputs.tfvars
helm_release.external_apps["grafana-agent-operator"]: Refreshing state... [id=grafana-agent-operator]
helm_release.external_apps["ingress-nginx"]: Refreshing state... [id=ingress-nginx]
helm_release.external_apps["prometheus"]: Refreshing state... [id=prometheus]
helm_release.external_apps["opentelemetry-collector"]: Refreshing state... [id=opentelemetry-collector]
helm_release.external_apps["grafana"]: Refreshing state... [id=grafana]
helm_release.external_apps["loki"]: Refreshing state... [id=loki]
kubernetes_namespace.homelab_ns: Refreshing state... [id=homelab]
helm_release.external_ingresses["grafana"]: Refreshing state... [id=grafana-ingress]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
+ create
Terraform will perform the following actions:
# helm_release.external_apps["grafana-agent-operator"] will be created
+ resource "helm_release" "external_apps" {
+ atomic = false
+ chart = "grafana-agent-operator"
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value:



Beyond Full Stack Engineer | McKinsey & Company

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store