Kubernetes the hard way, automated
Kubernetes from Scratch
A five-VM Kubernetes cluster built the hard way on Apple Silicon Macs, with no kubeadm. Ansible lays down the PKI, etcd, control plane, kubelets and networking, and checks the cluster's health between stages.
- Kubernetes
- Ansible
- Terraform
- Cilium

- VMs, from bare Macs
- 5VMs, from bare Macs
- Ansible roles
- 21Ansible roles
- retrying health gates
- 7retrying health gates
- kubeadm
- 0kubeadm
Why I built it
kubeadm hides the parts of Kubernetes that break in production: certificates, etcd, the order components start in, and how a kubelet earns its identity. Building every piece by hand is the most direct way to learn what each one needs.
What it does
- Prepares Apple Silicon Macs as VM hosts and installs Orchard to manage Tart VMs on them.
- Bakes one Tart image per node with a static IP, then has Terraform create five VMs:
master-1,master-2,worker-1,worker-2andlb-1. - Builds a cluster certificate authority and signs a certificate for every component.
- Installs etcd, the control plane, containerd and kubelets from upstream binaries as systemd units.
- Puts haproxy on
lb-1in front of both API servers on port 6443. - Installs Cilium, CoreDNS and metrics-server, and gives the laptop a working
kubectl.
How it works
Four playbooks and one Terraform apply run in order. bootstrap.yml prepares each Mac (Command Line Tools, a sudo user, optionally Tailscale). prerequisite.yml installs the Orchard controller, worker and CLI, sets up the Homebrew environment and creates a service account for Terraform. node-images.yml bakes a Tart image per node with its static IP. Terraform, in the separate k8sfs-terraform repo, then creates the VMs through Orchard's API. Finally site.yml builds the cluster with 14 roles.
Inventory comes from two places. In the DHCP environment, inventory/orchard_inv.py asks Orchard's REST API for /v1/vms and each VM's /v1/vms/<name>/ip, and groups hosts by name prefix. The static-IP environment uses a plain static inventory.
Certificates
master-1 creates a 10-year KUBERNETES-CA and a separate front-proxy CA with the community.crypto collection. It signs certificates for admin, the controller manager, the scheduler, the API server (with SANs for both masters and the load balancer), the API server's kubelet client, the etcd server, the service-account key pair and the front-proxy client. Secrets are encrypted at rest with a randomly generated key.
Kubelets don't get a pre-made certificate. They join with TLS bootstrapping: a bootstrap token lets each kubelet request its own certificates, the serving CSRs are approved automatically, and the play waits until every node's CSR is approved before it moves on. The two masters also run kubelets, tainted NoSchedule so workloads stay on the workers.
Health gates
Seven checks retry until they pass, so a broken stage stops the run where it broke instead of failing three roles later: etcdctl member list, componentstatuses, kubectl get nodes on the cluster, kubectl get nodes again from the laptop, the Cilium rollout plus the Gateway reaching Programmed, the CoreDNS rollout, and kubectl top nodes.
Why this stack
Tart runs Apple's Virtualization framework, so the VMs are native on Apple Silicon, and Orchard adds a REST API that both Terraform and the dynamic inventory can use. Ansible fits a build where order matters and each stage can be run on its own by tag. Cilium covers pod networking, LoadBalancer IPs through L2 announcements and Gateway API in one install, which suits a lab with no cloud load balancer.
The hard part
Ordering. Certificates must exist before etcd, etcd before the API servers, the API servers before kubelets can bootstrap, and kubelets before the CNI can roll out. When a stage fails quietly, the error shows up much later somewhere unrelated. The retrying health gates turned that into fast, local failures: each stage proves the cluster works before the next one starts.
Results
The playbooks and one Terraform apply take bare Macs to a five-VM cluster with two control-plane nodes behind a load balancer, Cilium networking with Gateway API, cluster DNS and resource metrics, reachable from the laptop with kubectl.
What I'd do differently
- etcd has two members, which is not highly available. Losing either member loses quorum. A third control-plane node, or a three-member etcd, fixes that.
- The single haproxy is a single point of failure. Two load balancers sharing a virtual IP (keepalived) would remove it.
- Monitoring stops at metrics-server. Prometheus and Grafana, with alerts on etcd and the API server, are the next layer.

