Installing a bare-metal Kubernetes cluster with Ansible

tjtharrison
4 min readSep 4, 2023

In a previous article (Setting up homelab 3.0) I described the initial installation of the latest iteration of my home lab environment running Kubernetes on 3x HP 800 G2 small form factor machines.

In this article, I’m going to be explaining in greater detail the process for installing Kubernetes with a few additional packages for better redundancy and easier accessibility from your network.

The Ansible project I used for deploying Kubernetes onto my new machines can be found here:

Photo by Growtika on Unsplash

Server provisioning

As there were only 3 machines to set up, I thought it would be overkill to do any disk cloning tool solutions (eg CloneZilla which I have used for larger projects in the past) so simply decided to download the latest LTS iso of Ubuntu from their download website and burn this onto a USB drive and complete the install manually on the servers.

While going through the installation process I set the hostname of the machines to their intended function within the cluster with static IP addresses, openssh with my public key attached:

hk8s-master
hk8s-node1
hk8s-node2

Nothing else particularly exciting was done during the setup, I noted during the Ubuntu server install process it did have the opportunity to install k3s but I wanted to do this “the hard way” to remind myself of the different components during the installation process.

Kubernetes installation

When all 3 servers were online and patched with the latest security updates — I started the process of writing the Ansible playbooks to install the necessary packages and configuration to run Kubernetes.

The playbook has had a number of improvements since first writing as I added more packages to the install script but has always consisted of 3 main playbooks:

  • The first playbook installs all…

--

--