Scripts Reference¶
KubeAuto uses five Bash scripts for cluster provisioning. All scripts use set -euo pipefail for strict error handling.
Script Execution Order¶
| Order | Script | Runs On | Phase |
|---|---|---|---|
| 1 | 01-common.sh | All nodes | 1 |
| 2 | 02-kubernetes.sh | All nodes | 2 |
| 3 | 03-controlplane.sh | Control plane | 3 |
| 3 | 04-worker.sh | Workers | 3 |
| — | 05-test.sh | Control plane | Manual |
01-common.sh — OS Preparation¶
Runs on: All nodes (Phase 1)
Purpose: Prepares the operating system for Kubernetes installation.
Actions:
- Disables swap permanently —
swapoff -aand comments out the swap entry in/etc/fstab - Updates APT package index
- Installs prerequisite packages:
apt-transport-https,ca-certificates,curl,gnupg,lsb-release - Loads kernel modules:
overlayandbr_netfilter(persisted to/etc/modules-load.d/k8s.conf) - Applies sysctl settings: enables
bridge-nf-call-iptables,bridge-nf-call-ip6tables,net.ipv4.ip_forward(persisted to/etc/sysctl.d/k8s.conf) - Persists PRIMARY_IP to
/etc/environment
02-kubernetes.sh — Kubernetes Installation¶
Runs on: All nodes (Phase 2)
Purpose: Installs the container runtime and Kubernetes tooling.
Actions:
- Installs containerd via APT
- Configures containerd — generates default config and patches
SystemdCgroup = true - Detects Kubernetes version — fetches the latest stable minor version from
https://dl.k8s.io/release/stable.txt - Adds Kubernetes APT repo with GPG keyring for the detected version
- Installs
kubelet,kubeadm,kubectland holds them at the installed version withapt-mark hold - Configures crictl to use the containerd socket
- Sets KUBELET_EXTRA_ARGS in
/etc/default/kubeletto bind kubelet toPRIMARY_IP - Enables and reloads kubelet via systemd
03-controlplane.sh — Cluster Initialisation¶
Runs on: Control plane only (Phase 3)
Purpose: Initialises the Kubernetes cluster and deploys the CNI.
Actions:
- Runs
kubeadm initwith:--pod-network-cidr=$POD_CIDR--service-cidr=$SERVICE_CIDR--apiserver-advertise-address=$PRIMARY_IP
- Sets up kubeconfig for both
vagrantuser androot - Installs Calico CRDs from
calico/operator-crds.yaml - Deploys Tigera operator from
calico/tigera-operator.yaml - Polls Tigera operator for up to 3 minutes until the pod is
Running - Downloads and patches
calico/custom-resources.yaml(replaces default CIDR withPOD_CIDR) - Generates join command and writes to
/vagrant/join-command.sh - Polls kube-system until at least 6 pods are
Running - Prints summary of nodes, pods, and Tigera status
04-worker.sh — Worker Join¶
Runs on: Worker nodes only (Phase 3)
Purpose: Joins the worker node to the existing cluster.
Actions:
- Polls for
/vagrant/join-command.sh— checks every 5 seconds for up to 5 minutes (60 attempts) - Executes the join command using
bash /vagrant/join-command.sh - Exits with error if the join command is not found within the timeout
05-test.sh — Test Deployment¶
Runs on: Control plane only (manually)
Purpose: Validates the cluster by deploying a sample workload.
Actions:
- Deploys Apache httpd (alpine) as a 2-replica Deployment
- Waits up to 2 minutes for the Deployment to reach
Available - Exposes as NodePort service on port 80
- Queries worker IPs dynamically from the cluster
- Prints access URLs for every worker node using the assigned NodePort
Invocation: