Quick Summary
For this project, I wanted to work on my DevOps skills while also using some spare computers I received for free. The goal was to turn these 4 machines into a working Kubernetes cluster capable of running complex dockerized applications locally.
I wanted to simulate an AWS Elastic Kubernetes Service (EKS)-like setup where I could work on my project source code and then automatically deploy it to a cluster when I merged my working branch with the (main) branch of my repo. I wanted for this to be a fully integrated CI/CD pipeline where I controlled everything from the python source code to the bare metal components. The workflow should work something like this:
- A developer makes a change to the source code and pushes an update.
- The update is saved in the git repo and GitLab runs some automated tasks such as linting, etc.
- GitLab triggers a new docker image to be built using the new source code.
- The new image is automatically uploaded to the local container registry.
- GitLab updates the development repo (another separate repo that ArgoCD watches) that updates the image tag.
- ArgoCD sees the change and deploys the new image automatically to the K3s cluster.
To do this, I used several technologies which I’ll list here
- Docker (for providing a platform agnostic environment to run the underlying app)
- Ansible (for machine provisioning)
- Kubernetes (for container orchestration across multiple machines)
- ArgoCD (for managing the deployment of docker images in the Kubernetes environment)
- GitLab (for continuous integration and actions needed to trigger updates to the development repository)
Inspiration and Vision for this Project
A lot of what I implemented here, I learned during a school project. I’m a student at Ecole 42 in Paris, France. In February of 2026, I finished and presented a project called “Inception of Things” where we had to set up our own K3s cluster and CD automation using Kubernetes and ArgoCD. I’ll provide a link to the subject for those who would like read more. Inception of Things
This project was divided into 3 main parts:
- Use Vagrant (a virtual machine provisioning tool) to create 2 virtual machines, and make one a k3s server and the other a k3s worker.
- In a single vagrant box, load K3s and use Traefik to route traffic to one of 3 dockerized applications depending on the request’s Host header.
- Using K3d, install ArgoCD and create a CD pipeline that allows you to update and edit a dev image of a project automatically.
I had a lot of fun doing this project and I learned a lot. At the end of the project I felt like these 3 parts were meant to be combined. They each felt like a piece of a larger puzzle: creating a true Kubernetes cluster using multiple machines that manage a larger project. In school, we didn’t have access to physical hardware apart from a single computer in our computer lab, so we had to use vagrant to simulate multiple machines. When starting this project, I had 4 spare machines and I wanted to combine all 3 parts of this project into 1 seamless “production ready” cluster complete with an easy to use CI/CD pipeline.
Of note: I wanted to add GitLab CI to this which was available as bonus for this project, but I did not complete due to time constraints. Additionally, rather than using Vagrant and virtual machines, I used Ansible and real computers.
I don’t plan on opening this environment up to the internet which is why I feel safe sharing some of the details here 🙂
The vision for this project was to simulate deploying a web application to a production server that uses ArgoCD, GitLab, Ansible, and Kubernetes. I like the idea of working with a cluster because clusters are modular by nature and would allow anyone who’s self-hosting their websites to upgrade their hardware in a relatively easy way. I plan to take this experience forward with me when I finally learn AWS. I have a little AWS experience so far and I want a little more experience in deploying applications before I put my wallet on the line. At the time of writing this article, I’m hosting this blog on AWS, though that might change since it’s a little expensive/overkill to use AWS for this.
Background and Environment
I used 4 small desktop computers that I combined into a cluster. For those who don’t know, a cluster is single compute resource composed of multiple computers (often referred to as nodes) that work together in a way that make it seem like you have 1 large powerful computer. You can distribute the tasks of an application or multiple applications among several computers, combining the resources of all the machines available. I’ll be using Kubernetes to help me do this.
The basic topology will be:
node1 -> server (control plane) + some workloads
node2 -> worker
node3 -> worker
node4 -> worker
I received these 4 computers from a local small business that recently upgraded their infrastructure. They were going to throw these computers in the garbage and I figured I would have a better use for them. This would also allow me to practice my IT architecture & design skills.
Below is a photo of my server rack where I host a multitude of useful tools. This rack has a lot inside it and deserves a post on its own. To summarize quickly, at the top I have a UDM Pro which I use as a gateway/firewall. This is connected to a 16 port PoE switch. There are also 3 raspberry pi’s which I use for several self-hosted tools including a local DNS (pi-hole & unbound) and wiki.js which allows me to take careful notes of all of my projects.
If you’d like a server tour, I recently released a blog post you might find interesting! Homelab Tour – July 2026

Zooming in on the 4 computers for this project, you’ll see we have 3 HP EliteDesk 705 G4 DM 35W and a Dell Optiplex 3050 from 2019.

They each have a 250 GB hard drive (encrypted with LUKS) and 16 GB of RAM.
Cleaning
These computers came fairly dusty. I didn’t take any pictures but if you can imagine what a small desktop computer that hasn’t been dusted in 6 years looks like… that’s what they looked like. I used an air compressor to clean them out and quickly brushed off any thing else with a paper towel. They all looked fairly nice afterwards. Good enough for learning how to make a DevOps setup anyway!
Wiping the Hard Drives
The small business that I got these computers from originally didn’t want to give me the hard drives because they had business related information on them. I assured the previous owners that I could wipe the drives using a command that will write all zeros to the drives, effectively erasing all the data on them. They agreed as long as I sent screenshots of before and after.
I used another computer I had to mount the drives and ran sudo dd if=/dev/zero of=/dev/sdX bs=64M status=progress conv=fdatasync on each of the drives one after another.
Initial setup
Setting up the computers was as easy as loading the latest version of Debian onto a startup disk and installing the OS. If you play around with Linux at all, you would be familiar with this process. I then used the graphical installer and installed Debian with the usual settings. I also opted to encrypt my drives with LUKS. In hindsight, this seems like a pointless step since I won’t be using this cluster for production.
Next, I needed to run a CAT6 cable from each machine to my switch. This isn’t my favorite activity. I usually put on a YouTube video about science or something while I prepare the cables since this is somewhat mindless work. I needed 4 cables of the same length. I buy CAT6 cable in bulk 150 foot runs and cut them to size as needed.
Some important tools you would need for this include:
CAT6 Cable (enough for 4 runs)
RJ45 Plugs (8 total)
A RJ45 Crimping Tool
A Cable tester (not required but saves you some headache)

After getting all the cables ready, I positioned the 4 computers on a rack mountable shelf and mounted the shelf where it would fit and not interfere with anything else. You can’t see it from photo, but behind the computers are 4 power adapters. They’re basically laptop chargers that plug into each computer. They’re right behind the computers and behind that is a power strip.
Next we’ll need to power on all the machines. So we plug each of them into the power strip as neatly as we can and plug the power strip into the UPS. Now we can power up the devices. We connect each of them to the monitor and keyboard one after another so we can enter the LUKS password. This is a tedious task that can be avoided by not encrypting your drives.
Then with Debian loaded on the machines, and everything wired up and powered on, we can start the initial configuration.
Initial Config
The first step is to make sure we can SSH into each machine. I went into the UDM Pro’s web interface and got the IP address for each machine and SSH’d into each of them.

For each of these boxes, I needed to add my laptop’s public key to the ~/.ssh/authorized_keys file. The first time I connected with SSH, I logged in with a password. Since I wasn’t using a key, there was no ~/.ssh/authorized_keys file. I needed to add my public key so that I didn’t get locked out when I started provisioning. The provision will include stricter SSH rules that will prevent password authentication.
An easy way to manage the servers will be to use 2 SSH keys: a default one for connecting with a terminal, and another one called “Ansible” that will be used to connect and run commands with our provisioning tool (Ansible).
To implement this, run:
ssh-keygen -t ed25519 -C "drew default" # If you don't already have a default ssh key
ssh-keygen -t ed25519 -C "ansible" # for ansible
At this point, I had 2 SSH keys for this project. I moved these keys over to the servers using an easy copy command.
ssh-copy-id -i ~/.ssh/default.pub <node1_ip>
ssh-copy-id -i ~/.ssh/ansible.pub <node1_ip>
ssh-copy-id -i ~/.ssh/default.pub <node2_ip>
ssh-copy-id -i ~/.ssh/ansible.pub <node2_ip>
ssh-copy-id -i ~/.ssh/default.pub <node3_ip>
ssh-copy-id -i ~/.ssh/ansible.pub <node3_ip>
ssh-copy-id -i ~/.ssh/default.pub <node4_ip>
ssh-copy-id -i ~/.ssh/ansible.pub <node4_ip>
Once finished, each of our servers will have a ~/.ssh/authorized_keys file with both of the SSH public keys inside it.
Lastly, I created static DHCP leases for my 4 computers to save me some headache later on.
At this point, I can access each machine via SSH from my laptop.
Provisioning with Ansible
One of the things I loved about Vagrant is that you can define exactly how to set up your newly created virtual machine. There is something very satisfying about loading up a brand new OS and automatically installing all the stuff you want, exactly the way you want it. While Vagrant only lets us provision virtual machines, Ansible lets us provision real computers as well as virtual machines. We can also provision multiple servers simultaneously. This makes it the perfect tool for this use case.
Ansible also does not require any agent to be installed on the target machine, so we can provision the servers from our laptop.
For now, rather than go into all the details of my Ansible files, I’ll show you the output for tree . for my project directory and explain a couple things about architecture.
.
├── ansible.cfg
├── group_vars
│ └── all.yml
├── host_vars
│ ├── node1.yml
│ ├── node2.yml
│ ├── node3.yml
│ └── node4.yml
├── inventory.ini
├── playbooks
│ └── setup-harden.yml
├── roles
│ ├── apparmor
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml
│ ├── auditd
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── templates
│ │ └── auditd-hardening.rules.j2
│ ├── common
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml
│ ├── docker
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml
│ ├── fail2ban
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── templates
│ │ └── jail.local.j2
│ ├── monitoring
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── templates
│ │ └── monitoring.sh.j2
│ ├── pam
│ │ └── tasks
│ │ └── main.yml
│ ├── ssh
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
│ ├── sudo_logging
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml
│ ├── ufw
│ │ └── tasks
│ │ └── main.yml
│ └── users
│ └── tasks
│ └── main.yml
└── tasks
├── post_tasks.yml
└── pre_tasks.yml
There might be a better way of doing this, but I’m a big fan of making things modular and extensible early on in the project. Speaking broadly, I have my setup-harden.yml file where I define my roles. Each role is a logical section of code. For example, “common” basically just runs apt update && apt upgrade. Likewise, the PAM section just installs and configures PAM. I made this Ansible project to replace a server setup script that I had been using for about 2 years.
I had a project in Ecole 42 where we needed to make a bash script for hardening an Ubuntu server and I basically took this script and kept adding to it as I learned new security tools and best practices. For this project, I translated everything I had in my setup script to an Ansible project because I saw the benefits immediately. If you’re interested in the specific details of the code, feel free to reach out to me. I’d be happy to go into detail about it! I might post this repo a little later as well and link it here. I haven’t decided yet.
A note about creating ansible playbooks: creating these files requires a lot of trial and error to make sure you get things right. My suggestion is to create a VM on your machine using Virtual Box or another vm provider, then include that VM in your inventory.ini file. Take a snapshot before you run any playbooks. Then when you want to test a playbook, you can run it only on the VM, check the end result and make sure it does what you expect. If you mess something up, just re-load from the snapshot. This will speed up your development time a lot.
Patience is very important when making Ansible playbooks. I usually put on some peaceful music that makes me feel happy while I work. As with any programming work, there is a lot of troubleshooting and restarting until you get everything exactly the way that you want it.
Also, if you don’t know Ansible but would like to learn, this was a great tutorial series that I followed. Getting started with Ansible
With all that said and done, our servers can now be considered reasonably hardened and provisioned. However, all 4 of the nodes are identical. We still need to install Kubernetes on 1 master node and 3 worker nodes.
K3s Server Setup
Setting up K3s on our 4 computers is not terribly difficult. Considering our simple architecture (1 server, 3 workers), we only need to set up 2 types of machines: a k3s_server and a k3s_worker. The k3s worker is also sometimes called an agent in k3s documentation. K3s Docs. This is a great guide for understanding the lightweight version of Kubernetes.
The setup for these 2 systems is simple when you strip away the Kubernetes syntax.
[Server]
1. Install k3s server
2. Wait for server token and API server to initialize.
3. Save token in Ansible for use with workers.
[Worker]
1. Install k3s agent using the token from the server
Similar to our setup/hardening script, this is easier to do when we focus on a single VM rather than the whole cluster at once.
Here is my VM at this point:

And the snapshots:

So far, I have only run the setup and harden playbook. K3s is not installed.
At this point, I began the process of creating my K3s installation script. Here it is in it’s entirety. I’ll go through it piece by piece.
---
- name: Install k3s on a single machine
hosts: vm-test-server
become: true
gather_facts: true
vars:
k3s_token_path: /var/lib/rancher/k3s/server/node-token
k3s_install_script_url: https://get.k3s.io
k3s_install_script_path: /tmp/k3s-install.sh
k3s_common_packages:
- curl
- ca-certificates
tasks:
# Install k3s packages needed for both servers and workers
- name: Install k3s common packages
ansible.builtin.apt:
name: "{{ k3s_common_packages }}"
state: present
update_cache: true
# Change host name of each node to the name in inventory
- name: Ensure hostname is set to inventory name
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
- name: Ensure hostname resolves locally
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1\s+'
line: "127.0.1.1 {{ inventory_hostname }}"
owner: root
group: root
mode: "0644"
# Disable the swap (recommended for k3s)
- name: Disable active swap
ansible.builtin.command: swapoff -a
when: ansible_swaptotal_mb > 0
changed_when: true
- name: Disable swap entries in /etc/fstab
ansible.builtin.replace:
path: /etc/fstab
regexp: '^([^#].*\s+swap\s+.*)$'
replace: '# \1'
backup: true
# Install k3s
- name: Download k3s install script
ansible.builtin.get_url:
url: "{{ k3s_install_script_url }}"
dest: "{{ k3s_install_script_path }}"
mode: "0755"
- name: Install k3s server
ansible.builtin.command: >
{{ k3s_install_script_path }} server --write-kubeconfig-mode "0644"
args:
creates: /usr/local/bin/k3s
- name: Enable and start k3s service
ansible.builtin.service:
name: k3s
enabled: true
state: started
- name: Wait for k3s token
ansible.builtin.wait_for:
path: "{{ k3s_token_path }}"
state: present
timeout: 120
- name: Wait for k3s API server readiness
ansible.builtin.command: k3s kubectl get --raw=/readyz
register: k3s_readyz
changed_when: false
retries: 30
delay: 2
until: k3s_readyz.rc == 0
# Verify Cluster (should be dev cluster of 1)
- name: Get K3s nodes
ansible.builtin.command: k3s kubectl get nodes -o wide
register: k3s_nodes_wide
changed_when: false
- name: Show K3s nodes
ansible.builtin.debug:
var: k3s_nodes_wide.stdout_lines
The first step is to install the prerequisite packages needed for this installation.
Next, we need to ensure that the hostname and the name that Ansible uses in the inventory are the same. This is not strictly necessary but it prevents any hostname related issues that may arise later on. Likewise, if we change the hostname, we need to change the /etc/hosts file and find and replace our hostname and our loopback address. Here I use a regex. Regex is also one of those things that feels like such a chore to learn, but once you understand them, they’re an incredibly invaluable tool for programmers. It makes find and replace functions much easier to perform. Ansible is built on python so if you can run a regex in python, you can run it here. For some practice, I learned with this amazing site: https://regex101.com/ I don’t know who made this, but hats off to you!
After that, we’re going to disable the swap on Debian. The K3s docs recommend doing this.
Installing K3s is pretty straightforward. The docs tell us to use this command curl -sfL https://get.k3s.io | sh - which we can translate to Ansible using the get_url module. We save this at the k3s_install_script_path. Then, we run the script with the subsequent Ansible task. Here we pass args: creates: /usr/local/bin/k3s which only runs the command if /usr/local/bin/k3s does not already exist. This is a builtin behavior of the command module that helps ensure things stay idempotent.
Next, we start the K3s service and use wait_for to wait until the token file is available. This step really isn’t necessary for a single server setup, but we’ll need it when porting this script over to a multi-machine setup.
Then, we wait for API server readiness. This API server specifically is for kubectl which is essentially the CLI layer between the user and the Kubernetes control plane.
Lastly, we just run a command to check that the nodes are available and print it out.
We’ll run ansible-playbook playbooks/vm-test-server-k3s-setup.yml to test our playbook.
We should get something similar to the following as an output:
➜ ansible git:(master) ✗ ansible-playbook playbooks/vm-test-server-k3s-setup.yml
Vault password:
PLAY [Install k3s on a single machine] *********************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************************************
ok: [node-test]
TASK [Install k3s common packages] *************************************************************************************************************************************************************
ok: [node-test]
TASK [Ensure hostname is set to inventory name] ************************************************************************************************************************************************
ok: [node-test]
TASK [Ensure hostname resolves locally] ********************************************************************************************************************************************************
changed: [node-test]
TASK [Disable active swap] *********************************************************************************************************************************************************************
changed: [node-test]
TASK [Disable swap entries in /etc/fstab] ******************************************************************************************************************************************************
changed: [node-test]
TASK [Allow K3s API from LAN] ******************************************************************************************************************************************************************
changed: [node-test]
TASK [Download k3s install script] *************************************************************************************************************************************************************
changed: [node-test]
TASK [Install k3s server] **********************************************************************************************************************************************************************
changed: [node-test]
TASK [Enable and start k3s service] ************************************************************************************************************************************************************
ok: [node-test]
TASK [Wait for k3s token] **********************************************************************************************************************************************************************
ok: [node-test]
TASK [Wait for k3s API server readiness] *******************************************************************************************************************************************************
ok: [node-test]
TASK [Get K3s nodes] ***************************************************************************************************************************************************************************
ok: [node-test]
TASK [Show K3s nodes] **************************************************************************************************************************************************************************
ok: [node-test] => {
"k3s_nodes_wide.stdout_lines": [
"NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME",
"node-test Ready <none> 2s v1.35.4+k3s1 10.0.2.15 <none> Debian GNU/Linux 13 (trixie) 6.12.86+deb13-amd64 containerd://2.2.3-k3s1"
]
}
PLAY RECAP *************************************************************************************************************************************************************************************
node-test : ok=14 changed=6 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Now that this playbook is working for a single node on our virtual machine, I would like to refactor the code a little in order to port it over to our cluster. I will divide it into 4 smaller conceptual pieces and add a few more details.
The 4 conceptual pieces are:
- Initialization and installation of base packages
- Server init \ API init \ token generation
- Worker init w/ token
- Verification of cluster
Migrating the K3s Playbooks to the Real Cluster
Once the single-VM K3s install was working, I refactored it into the same shape as the rest of the Ansible project: smaller roles that each do one part of the job. The VM was useful for proving the basic install flow, but the real cluster needed a few extra details. Instead of one machine doing everything, I now had one control-plane node and three worker nodes that needed to join that control plane reliably.
The final cluster inventory looks like this:
[k3s_server]
node1
[k3s_workers]
node2
node3
node4
[k3s_cluster:children]
k3s_server
k3s_workers
From there, the cluster setup playbook runs in four phases:
- name: Prepare nodes for k3s
hosts: k3s_cluster
roles:
- k3s_common
- name: Install k3s server
hosts: k3s_server
roles:
- k3s_server
- name: Install k3s workers
hosts: k3s_workers
roles:
- k3s_worker
- name: Verify k3s cluster
hosts: k3s_server
roles:
- k3s_verify
The k3s_common role handles the work that every node needs before Kubernetes is installed. It installs the common packages, makes sure the system hostname matches the Ansible inventory name, updates /etc/hosts, and disables swap. This is the part that came almost directly from the single-VM test setup.
The k3s_server role is where the real cluster starts to differ from the VM. On node1, Ansible opens the Kubernetes API port 6443 to the LAN, downloads the official K3s install script, installs K3s in server mode, starts the k3s service, and waits for the API server to become ready. After that, it reads the K3s node token from:
/var/lib/rancher/k3s/server/node-token
That token is the important piece that allows the worker nodes to join the cluster. The playbook uses slurp to read it, decodes it, and stores it as an Ansible fact on the server host. I also marked those token-related tasks with no_log: true so the token does not get printed into the terminal output.
The k3s_worker role then runs on node2, node3, and node4. Each worker looks up the primary K3s server from the inventory, builds the API URL from the server IP, and runs the same K3s install script in agent mode using two environment variables:
K3S_URL=https://<server-ip>:6443
K3S_TOKEN=<token-from-node1>
After the agent is installed, Ansible enables and starts the k3s-agent service so each worker rejoins the cluster automatically after a reboot.
The final role, k3s_verify, runs back on the server node. It waits until kubectl get nodes shows the expected number of nodes, then prints kubectl get nodes -o wide. This gives a quick sanity check that the control-plane node and all three workers are visible and ready.
The end result is basically the same flow as the VM test, but split across the real topology:
- Prepare every node.
- Install the server on
node1. - Read the server join token.
- Install agents on
node2,node3, andnode4. - Verify that the full cluster is online.
This was the point where the project stopped being a local Kubernetes experiment and became a real four-machine K3s cluster.
K3s Worker Setup
Next, we’ll look at the K3s worker setup. The worker nodes’ playbooks are a lot shorter than the server node’s.
k3s_worker/tasks/main.yml
---
- name: Set K3s primary server fact
ansible.builtin.set_fact:
k3s_primary_server: "{{ groups[k3s_server_group][0] }}"
- name: Download K3s install script
ansible.builtin.get_url:
url: "{{ k3s_install_script_url }}"
dest: "{{ k3s_install_script_path }}"
mode: "0755"
- name: Install K3s agent
ansible.builtin.command: "{{ k3s_install_script_path }}"
args:
creates: /usr/local/bin/k3s
environment:
K3S_URL: "{{ k3s_api_url }}"
K3S_TOKEN: "{{ hostvars[k3s_primary_server].k3s_node_token }}"
no_log: true
- name: Enable and start k3s-agent service
ansible.builtin.service:
name: k3s-agent
enabled: true
state: started
Here we are going to set up the workers. Before downloading and installing Kubernetes, we need to get the server token so that we can pass it as a command line argument to the setup script. We pull this from the server host and save it as a fact on our worker node. Keep in mind that this task is being run 3 times: once for each worker node. We are saving the token 3 times locally, once for each worker node, and then using it to set up and connect our agent.
Finally, we enable our k3s-agent service. When we enable a service like with sudo systemctl enable ssh for example, this tells the OS that we want to start this service when we boot the machine.
K3s Cluster Verify
Lastly, let’s look at k3s_verify/tasks/main.yml.
---
- name: Wait for expected number of K3s nodes
ansible.builtin.command: k3s kubectl get nodes --no-headers
register: k3s_nodes
changed_when: false
retries: 30
delay: 5
until: k3s_nodes.stdout_lines | length >= groups['k3s_cluster'] | length
- name: Get K3s nodes
ansible.builtin.command: k3s kubectl get nodes -o wide
register: k3s_nodes_wide
changed_when: false
- name: Show K3s nodes
ansible.builtin.debug:
var: k3s_nodes_wide.s
This file runs on only the server node and pauses execution of the playbook until the number of nodes matches the size of the cluster. Then we print the kubectl get nodes -o wide command which shows what our cluster looks like.
drew@node1:~$ sudo kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
node1 Ready control-plane 4m v1.35.4+k3s1 <ip addr> <none> Debian GNU/Linux 13 (trixie) 6.12.85+deb13-amd64 containerd://2.2.3-k3s1
node2 Ready <none> 2m v1.35.4+k3s1 <ip addr> <none> Debian GNU/Linux 13 (trixie) 6.12.85+deb13-amd64 containerd://2.2.3-k3s1
node3 Ready <none> 2m v1.35.4+k3s1 <ip addr> <none> Debian GNU/Linux 13 (trixie) 6.12.85+deb13-amd64 containerd://2.2.3-k3s1
node4 Ready <none> 2m v1.35.4+k3s1 <ip addr> <none> Debian GNU/Linux 13 (trixie) 6.12.86+deb13-amd64 containerd://2.2.3-k3s1
This seems complicated, mostly because there are 6 files working together, but in essence, we are doing exactly what we did in the single VM setup, except we’re passing the node token on the workers in order to set them up.
At this point, we have a cluster of computers, each hardened, k3s installed and connected to a designated server node.
ArgoCD Setup
With the cluster running, the next piece was ArgoCD. ArgoCD is the GitOps controller in this setup. Instead of manually applying Kubernetes YAML files every time I want to deploy something, ArgoCD watches a Git repository and keeps the cluster synchronized with whatever is defined there.
In my setup, Ansible installs ArgoCD directly onto the K3s cluster from the control-plane node. The playbook creates an argocd namespace and applies the upstream ArgoCD install manifest:
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
The playbook also installs the argocd CLI on the server node. That is not strictly required for ArgoCD to run, but it is useful when managing or debugging ArgoCD from the command line.
After the base install, I configured ArgoCD to be reachable through Traefik at:
https://argocd.lan:8443
This required a few extra steps. The playbook creates a local TLS directory, generates a self-signed certificate for argocd.lan, stores it in Kubernetes as a TLS secret, and creates an Ingress resource that points Traefik to the argocd-server service. I also patched ArgoCD’s command parameters so the ArgoCD server runs in server.insecure mode behind the ingress. In this case, Traefik handles the HTTPS connection from the browser, and ArgoCD receives the request behind that ingress layer.
One networking issue I ran into was different from the VM setup. In the VM, every pod and every Kubernetes component lived on the same machine. On the real cluster, ArgoCD pods could run on worker nodes while Traefik or the service load balancer could be handling traffic on another node. That means cross-node pod networking has to work correctly.
The important firewall rule was allowing Flannel VXLAN traffic on UDP port 8472 between nodes:
- name: Allow K3s flannel VXLAN
community.general.ufw:
rule: allow
from_ip: "192.168.2.0/24"
to_port: "8472"
proto: udp
comment: K3s flannel vxlan
Flannel is the CNI layer K3s uses by default to let pods communicate across nodes. Without that rule, the cluster could look mostly healthy, but ingress traffic would not reliably reach pods running on other machines.
Once ArgoCD was reachable in the browser, I used the initial admin password from the Kubernetes secret:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
From there, ArgoCD can be pointed at the deployment repository. The important idea is that ArgoCD is not watching the application source code directly. It watches the Kubernetes deployment repository. That repository contains the YAML files that define what should be running in the cluster.
GitLab Setup
GitLab became the local source control and CI/CD piece of the project. I am going to keep this part short here because the GitLab setup deserves its own write-up. I’m not promising I’ll make one by the way 😛 .
In this setup, GitLab runs on a separate machine called server1, not inside the K3s cluster. Ansible provisions it with Docker Compose using the official GitLab EE image. The container stores its persistent data under:
/srv/gitlab
The compose configuration exposes the GitLab web UI over HTTPS at gitlab.lan, includes SSH access for Git operations, and enables the built-in GitLab container registry:
GitLab web: https://gitlab.lan:8443
Registry: https://gitlab.lan:5050
I also added a GitLab Runner on the same server1. That runner runs as a Docker container and mounts the Docker socket, which allows CI jobs to build container images. The rough flow is:
- Push application source code to GitLab.
- GitLab CI runs through a GitLab Runner.
- The runner builds a Docker image.
- The image is pushed to the local GitLab container registry.
- The deployment repository is updated with the new image tag.
- ArgoCD notices the deployment repo changed and syncs the cluster.
This is one of those parts that sounds simple after it is working, but it involved a lot of small details. GitLab is acting like my local GitHub, CI engine, and image registry all at once.
Using Nginx Proxy Manager for SSL Certificates
While I was setting up GitLab, I had been struggling with self-signed certs. At first, I thought a self-signed cert here or there wouldn’t be too much of a hassle. When I was only dealing with the self-signed certs from ArgoCD, they felt manageable. However, after I started to set up GitLab, I realized that this problem was about to become very annoying. In GitLab, you need certs for the Web GUI but also the runners need certs as well. My runners were running inside of Docker, so I had to pass my certs from GitLab (which was inside a docker container), then move them outside of the container and into the container for the runner. Getting all of this to work was a headache. Then, the prospect of getting it to work in Ansible so I could have an automated setup, made me rethink a few things.
Ultimately, I decided to redesign things. On server1 I installed Nginx Proxy Manager (NPM) in order to use SSL certificates signed by a certificate authority (CA). In hindsight, I should have done this before I even started the project because it eliminated the need for self-signed certs. I could feel the benefits of this across my entire HomeLab, not just this cluster project.
In general, NPM gave me one central place to manage HTTPS for the services running in my HomeLab. Instead of creating, trusting, copying, and mounting self-signed certificates across GitLab, runners, the container registry, ArgoCD, and other services, I can put Nginx Proxy Manager in front of them and let it request real CA-signed certificates through Let’s Encrypt. This makes the setup cleaner, easier to automate, and less fragile because each internal service no longer needs its own custom certificate workaround. It also gives the project a more production-like design: services can be reached through normal domain names, browsers and tools trust the certificates automatically, and future applications can be added behind the proxy without repeating the same SSL problems.
For the most part, I followed this tutorial for setting up NPM: https://www.youtube.com/watch?v=P3imFC7GSr0. In my own setup, I used the docker-compose.yml file that was listed in the NPM docs, but I changed a couple settings. For example, I gave the database a more secure password.
From here forward, you’ll see me use <local domain>, in my explanations. This is the public address that I used with NPM to get the CA signed certificates. Obviously, if you do this for yourself, you’ll have your own domain that you’ll be using. Any domains that I was using prior to this like gitlab.lan and argocd.lan I later changed to gitlab.<local domain> and argocd.<local domain>. An example address would be https://gitlab.example.com.
One final note: because I also have my own DNS running on my local network, I also needed to make a DNS record for each new domain. I added records for gitlab.<local domain>, etc. and pointed them to the IP address of the machine running Nginx Proxy Manager. Basically, the router (UDM Pro) sees a packet destined for a specific address, it uses my Pi-Hole w/ Unbound DNS to resolve the address, that points to server1, which is hosting Nginx Proxy Manager, NPM gets the request and looks at the subdomain and then routes the request to the correct IP on the network, UFW firewall rules allow the request in. Lastly, in the case of our cluster, Traefik handles the ingress and forwards the packet to the pod that will be responding to the request. Very Simple! 😀
Deploying the Test App with GitOps
At this point, the project has the pieces needed for a small GitOps deployment:
GitLab -> source code, CI jobs, container registry
Deployment repo -> Kubernetes YAML watched by ArgoCD
ArgoCD -> syncs desired state into K3s
K3s cluster -> runs the application
Traefik -> routes HTTP traffic into the app
To give a quick overview of what the deployment repository looks like, here is the output from tree .:
.
├── plain_yaml
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
└── README.md
The deployment repository currently defines a small test application in the dev namespace. The deployment is named k3s-cluster-test-app and runs one replica:
[deployment.yaml]
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: k3s-cluster-test-app
namespace: dev
spec:
replicas: 1
revisionHistoryLimit: 3
selector:
matchLabels:
app: k3s-cluster-test-app
template:
metadata:
labels:
app: k3s-cluster-test-app
spec:
imagePullSecrets:
- name: gitlab-registry-secret
containers:
- image: registry.<local domain>/drew_group/k3s_cluster_test_app:dbcbb3a9
name: k3s-cluster-test-app
ports:
- containerPort: 80
The container image is pulled from the local container registry.
The deployment also references an image pull secret:
imagePullSecrets:
- name: gitlab-registry-secret
That secret allows Kubernetes to authenticate to the private GitLab registry and pull the image.
The service exposes the pod internally on port 80. This is fine for internal traffic.
[service.yaml]
---
apiVersion: v1
kind: Service
metadata:
name: k3s-cluster-test-app
namespace: dev
spec:
ports:
- port: 80
targetPort: 80
selector:
app: k3s-cluster-test-app
Finally, the ingress tells Traefik how to route browser traffic to that service:
[ingress.yaml]
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: k3s-cluster-test-app
namespace: dev
spec:
ingressClassName: traefik
rules:
- host: cluster.<local domain>
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: k3s-cluster-test-app
port:
number: 80
So when a request comes in for cluster.<local domain>, Traefik matches that host rule, forwards the request to the k3s-cluster-test-app service, and the service sends it to the running pod.
This is a small app that I created to prove that the cluster works, but you could put any dockerized application here and it should be accessible over HTTPS. The image comes from a local GitLab registry, the Kubernetes manifests live in a separate deployment repository (another repo in GitLab), ArgoCD watches the deployment repository, and the K3s cluster deploys whatever the repo says should be running.
Now, when we navigate to https://cluster.<local domain> in our browser we should see our sample web app running.

And we can see which node the pod is running on:
drew@node1:~$ sudo kubectl get pods -n dev -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
k3s-cluster-test-app-75c7c7f458-bgf87 1/1 Running 0 5m <local ip> node2 <none> <none>
We only have 1 pod running 1 version of our applicaiton because we have the number of replicas currently set to 1 in our deployment.yaml file. But we could bump this up to 3 or 5 or whatever we’d like.
And if we log into ArgoCD we should see a nice display of our cluster with our 1 pod running (in green) all the way on the right!

Summary
The final result is a working local deployment platform built on spare hardware. The 4 physical machines are provisioned with Ansible, hardened with reusable roles, and joined to a K3s cluster with node1 as the control-plane node and node2, node3, and node4 as workers.
On top of that, ArgoCD provides the GitOps layer. Instead of treating Kubernetes like something I manually poke with kubectl, the cluster now has a source of truth in Git. When the deployment repository changes, ArgoCD can detect that change and apply it to the cluster.
GitLab fills in the other side of the workflow. It gives me local Git repositories, CI/CD jobs, a GitLab Runner for building images, and a private container registry for storing those images. The K3s nodes trust the local registry certificate, and the application deployment uses an image pull secret to pull private images from that registry.
The test app is intentionally small, but it proves the workflow:
- Build an image.
- Push it to the local registry.
- Reference that image from Kubernetes YAML.
- Let ArgoCD sync the desired state.
- Reach the app through Traefik at
cluster.<local domain>.
This is not AWS, and it is not meant to be a public production platform, but it does model many of the same ideas: infrastructure as code, repeatable provisioning, private image builds, GitOps deployments, ingress routing, and a cluster made of multiple machines instead of one server running a few containers.
The most useful part of this project is that each layer is now understandable and replaceable. I can change the app without rebuilding the cluster. I can change the deployment manifests without touching the application source code. I can rerun Ansible to rebuild the machines or add more machines if I want. And I can use ArgoCD to keep the running cluster tied to what is written in Git.
For a pile of old desktop computers that were going to be thrown away, this feels like a pretty good outcome.
Things I Would Change If I Did This Again
If I started this project from scratch today, the main thing I would change would the the self-signed certs for GitLab and ArgoCD. Since doing this project, I started using Nginx Proxy Manager. This tool essentially eliminates the issues I was having with the self-signed certs. I highly recommend installing Nginx Proxy Manager before getting too far into this project. It’ll save you a lot of headache in the long run.
One Final Word
I’ve intentionally left my source code private for this project. I’m not sure if I want to use my Ansible playbooks someday for a real deployment or not. For that reason, I’d like to keep them off of GitHub. However, if you would like to see my code or read over it for yourself, please reach out. I’m OK with sharing my code with individuals who share an interest in this sort of thing.
Thanks!
I want to thank you for reading this write-up for my project. I had a lot of fun working on this project and I’m a little amazed that someone would read all of this. For me, doing a write-up of my projects is part of the learning process. I don’t really expect someone to read this, but if you did, I hope you learned something! I love working on computer science projects and I hope this might inspire someone else to use some old computer hardware in a creative way, and maybe learn something in the process.
Thanks again!
– Drew








