Up to Main Index                           Up to Journal for October, 2025

                    JOURNAL FOR SUNDAY 26TH OCTOBER, 2025
______________________________________________________________________________

SUBJECT: Creating Kubernetes clusters from scratch
   DATE: Sun 26 Oct 19:13:27 GMT 2025

Recently I have been very busy working with Kubernetes clusters. For local
development and testing I previously used minikube to create a quick cluster.
minikube is fantastic but… it has limitations and I needed a more authentic
setup for the work I am doing.

There is no way I can afford a cluster in the cloud so time to roll my own…

Creating a cluster can be very discouraging. Going it alone and building your
own cluster is a very different experience to simply clicking "Create Cluster"
on AWS, Azure or GCP. All of the online guides I found seemed to either be
clones of each other, or simply did not work. As a result I've had to muddle
my way through how to make everything work myself - and there are a lot of
moving parts to this little project.

All of that learning I have put into a BASH script called 'cluster-setup'. The
script lets me create a control node from scratch on Debian Trixie in about 10
minutes. It then lets me add additional nodes just as quickly.

The basic process is:

  - setup minimal install information: node name, control node IP address,
    local username, a SSH public key for remote access
  - perform a base Debian Trixie install (base utils+SSH server)
  - copy script to machine and run it

The control node will be setup with a private registry you can push container
images to for deployment, flannel for pod networking, the metrics server and
the Kubernetes dashboard.

If you want you can stop there with a single node. The control node will been
untainted and allow pods to be scheduled on it.

In order to add more nodes, tweak some script settings and repeat the 3 steps
above on each machine you want to add as a node in the cluster.

While writing this I have a cluster running with two nodes using KVM+Qemu on
my desktop. Each node has 6 CPU, 16Gb RAM and 25Gb storage:


    >kubectl get nodes
    NAME        STATUS   ROLES           AGE   VERSION
    phreaks12   Ready    control-plane   95m   v1.34.1
    phreaks14   Ready    <none>          83m   v1.34.1
    >kubectl get pods --all-namespaces
    NAMESPACE              NAME             READY   STATUS    RESTARTS   AGE
    kube-flannel           kube-flannel-…   1/1     Running   0          96m
    kube-flannel           kube-flannel-…   1/1     Running   0          83m
    kube-system            coredns-64dcc…   1/1     Running   0          78m
    kube-system            coredns-64dcc…   1/1     Running   0          78m
    kube-system            etcd-phreaks1…   1/1     Running   0          96m
    kube-system            kube-apiserve…   1/1     Running   0          96m
    kube-system            kube-controll…   1/1     Running   0          96m
    kube-system            kube-proxy-2q…   1/1     Running   0          83m
    kube-system            kube-proxy-jd…   1/1     Running   0          96m
    kube-system            kube-schedule…   1/1     Running   0          96m
    kube-system            metrics-serve…   1/1     Running   0          78m
    kubernetes-dashboard   kubernetes-da…   1/1     Running   0          95m
    kubernetes-dashboard   kubernetes-da…   1/1     Running   0          95m
    kubernetes-dashboard   kubernetes-da…   1/1     Running   0          95m
    kubernetes-dashboard   kubernetes-da…   1/1     Running   0          95m
    kubernetes-dashboard   kubernetes-da…   1/1     Running   0          95m
    >


Not too shabby for about 10 minutes work - see below ;)

Because I am rebuilding the cluster a lot while testing and generally screwing
things up, I have a copy of the disk images taken after installing Debian. I
can then simply start over by replacing the disk image with the copy and then
re-run my script. By using disk copies I can create a new cluster in about 5
minutes per node. I can also create clones quickly to add as worker nodes.

The script also lets me experiment with different configurations easily. My
desktop has 24 cores and 64GB RAM. I can have 2 nodes with 8 CPU and 16Gb or 4
nodes with 4 CPU and 8Gb - and still have a snappy desktop with resources to
spare. The biggest cluster the desktop runs is 5 nodes; 4 CPU and 10Gb each.
With more nodes I taint the control node so pods are not scheduled on it.

Another reason for writing the script is that clusters do not like to be
shutdown. You can back-up etcd, scale everything to zero, cordon nodes and
drain them all you want. There is no guarantee the cluster will come back up
in a working state when you restart it. With the script it's easier to just
re-create the cluster.

The script makes creating a cluster simple, quick and repeatable. The Debian
image I am using is debian-13.1.0-amd64-netinst.iso coming in at 783Mb. I hope
with my script anyone will be able to use it to create their own Kubernetes
cluster, even if it is just a single node.

If you feel ambitious, the script is just 531 lines of BASH. I will encourage
you to customise it, hack it and make it your own to suit your needs.

I still have some testing, documenting and polishing to do before I release
the script. As I need this for me anyway, it will be released soon! I plan to
put it in the annex with a full how-to guide. I'm currently experimenting with
Alpine Linux instead of Debian for building lightweight clusters. I'm not sure
if that should be the version released or if I'll release two versions.

My small clusters may pale in comparison to the 50 node (3,200 CPUs, 7Tb+ RAM)
clusters I have worked with. But, it is running the same Kubernetes software
and other components under the hood.

Kubernetes was created when people were orchestrating Docker containers with
BASH scripts, now I'm scripting Kubernetes clusters with BASH scripts…

--
Diddymus


  Up to Main Index                           Up to Journal for October, 2025