How to Set Up a Kubernetes Cluster: A Step-by-Step Guide for Beginners
Kubernetes is the industry standard for container orchestration. Setting up a cluster manually with kubeadm gives you full control and a clear understanding of its architecture. This guide walks you through the essential steps.
Before you begin, you need at least two Ubuntu 22.04 machines—one control plane and one worker node—with 2GB RAM and 2 CPUs each. Verify that both can reach the internet and a container image registry.
Step 1: Install Dependencies
On both nodes, install containerd, kubeadm, kubelet, and kubectl. Enable the required kernel modules, add the official Kubernetes repository, and hold the package versions to prevent unexpected upgrades.
Step 2: Initialize the Control Plane
On the master node, run sudo kubeadm init --pod-network-cidr=10.244.0.0/16. Once it finishes, copy the generated kubeconfig file to your home directory so kubectl can communicate with your cluster.
Step 3: Join Worker Nodes
The initialization command outputs a kubeadm join command containing a token. Run this command on each worker node with sudo privileges, then confirm their status with kubectl get nodes.
Step 4: Deploy a Pod Network
A CNI plugin such as Calico or Flannel is required for pod-to-pod communication. Apply the Calico manifest using the command kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/master/manifests/calico.yaml.
Once the network is deployed, all nodes will show Ready. You now have a working Kubernetes cluster, ready for deployments. Continue experimenting with kubectl to unlock its full potential.