How to Deploy Kubernetes on Bare Metal (Ubuntu)
This guide walks you through how I successfully deployed Kubernetes on bare metal using Ubuntu 22.04. We'll use kubeadm for cluster setup and containerd as the container runtime.
Perfect for labs, self-hosting, and dev environments where cloud isn't required.
Reference Git Repo: github.com/malcolmso/kube-install

Prerequisites
- 2+ Ubuntu 22.04 servers (1 master + 1+ workers)
- Root access on all nodes
- Internet connectivity
Step1: Prepare the Nodes
Install containerd, disable swap, and install Kubernetes components:
# Install containerd
sudo apt install -y containerd
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
sudo systemctl restart containerd
# Disable swap
sudo swapoff -a
sudo sed -i '/[[:space:]]swap[[:space:]]/ s/^/#/' /etc/fstab
# Install Kubernetes packages
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gpg socat docker.io
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | \
sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] \
https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | \
sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm
# (Optional) Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Step2: Initialize the Control Plane
Run these commands on the master node:
# Enable IP forwarding
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo sed -i 's/^#*net.ipv4.ip_forward=.*/net.ipv4.ip_forward=1/' /etc/sysctl.conf
sudo sysctl -p
# Pull required images and initialize cluster
sudo kubeadm config images pull
sudo kubeadm init
Note: Save the kubeadm join
command shown at the end โ youโll need it for the worker nodes.
# Configure kubectl for your user
mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step3: Install Pod Network (Calico)
Install Calico to enable pod-to-pod networking across nodes:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
kubectl get nodes
Step4: Join Worker Nodes
On each worker node, enable networking and join the cluster using the token from Step 2:
# Enable IP forwarding
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo sed -i 's/^#*net.ipv4.ip_forward=.*/net.ipv4.ip_forward=1/' /etc/sysctl.conf
sudo sysctl -p
# Join the cluster
sudo kubeadm join <control-plane-ip>:6443 --token <token> \
--discovery-token-ca-cert-hash sha256:<hash>
Wrapping Up
- Deploy applications using
kubectl
- Monitor your cluster using Prometheus and Grafana
- Explore advanced topics like Helm, RBAC, and network policies