create a Kubernetes single-node cluster on Ubuntu 22.
04 using kubeadm with
containerd as the container runtime, and Calico as the pod network:
Kubernetes Single Node Cluster Setup with containerd on Ubuntu 22.04 (Kubernetes
v1.30.x)
Prerequisites
Ubuntu 22.04 system (can be WSL or VM)
System updated and br_netfilter module loaded
Container runtime set to containerd
Here is a comprehensive step-by-step guide to create a Kubernetes single-node
cluster on Ubuntu 22.04 using kubeadm with containerd as the container runtime, and
Calico as the pod network:
## Kubernetes Single Node Cluster Setup with containerd on Ubuntu 22.04 (Kubernetes
v1.30.x)
### Prerequisites
- Ubuntu 22.04 system (can be WSL or VM)
- System updated and `br_netfilter` module loaded
- Container runtime set to containerd
### Step 1: Prepare the system
Updated system and load necessary kernel modules:
```bash
sudo apt update && sudo apt upgrade -y
sudo modprobe br_netfilter
lsmod | grep br_netfilter
```
Enable required kernel parameters for Kubernetes networking:
```bash
sudo tee /etc/modules-load.d/k8s.conf <<EOF
br_netfilter
EOF
sudo tee /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
```
### Step 2: Install containerd
Install containerd as the container runtime:
```bash
sudo apt install -y containerd
```
Configure containerd to use the default Kubernetes CRI settings:
```bash
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd
```
### Step 3: Remove old Kubernetes sources (if any)
```bash
sudo rm -f /etc/apt/sources.list.d/kubernetes.list
sudo rm -f /usr/share/keyrings/kubernetes-archive-keyring.gpg
```
### Step 4: Add Kubernetes repository for v1.30
```bash
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 update
```
### Step 5: Install Kubernetes components
```bash
sudo apt install -y kubelet kubeadm kubectl conntrack cri-tools ethtool socat
sudo apt-mark hold kubelet kubeadm kubectl
```
### Step 6: Initialize Kubernetes cluster
Initialize the cluster with containerd as runtime and specify the pod network CIDR
(for Calico):
```bash
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
```
### Step 7: Set up kubeconfig for the current user
Run the commands output by `kubeadm init`, typically:
```bash
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
```
### Step 8: Install Calico CNI plugin for networking
```bash
kubectl apply -f
https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/
calico.yaml
```
Wait 30-60 seconds for pods to initialize, then check:
```bash
kubectl get pods -n kube-system
kubectl get nodes
```
You should see your node in the `Ready` state.
### Troubleshooting
- Calico pods are stuck in `PodInitializing`, check the logs:
```bash
kubectl logs -n kube-system -l k8s-app=calico-node
```
- Verify kernel settings and modules are correctly loaded.
- Reapply Calico YAML if needed:
```bash
kubectl delete -f
https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/
calico.yaml
kubectl apply -f
https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/
calico.yaml
```
### Final verification
```bash
kubectl get nodes
kubectl get pods -A
```
All pods should show as `Running` and your single node should be `Ready`.
### Adding Worker Nodes
To add worker nodes, use the `kubeadm join` command output during the `kubeadm
init` step, for example:
```bash
kubeadm join 172.30.178.85:6443 --token baeaz1.wdu635eprhbzzwez \
--discovery-token-ca-cert-hash
sha256:5fafea6867d80c4cac1c16fff06ada9c9e58c65000a968d8d6f19eefa0d27d72
```
Copy this from your `kubeadm init` output to join other nodes.
This setup uses containerd as the container runtime and Calico as the networking
plugin on Kubernetes 1.30.x in Ubuntu 22.04, following a best practice approach for
single-node clusters. Let me know if you need the worker node installation details
or multi-node cluster setup!
How I Set Up a Kubernetes Single-Node Cluster Using kubeadm and Calico
Preparing the System:
First, I made sure my Ubuntu system was updated and ready for Kubernetes. I also
loaded a special kernel module called br_netfilter which helps Kubernetes handle
network packets properly.
Configuring Networking Settings:
Then, I configured some important network settings on the system. These settings
allow Kubernetes to manage network traffic between pods correctly.
Installing Kubernetes Tools:
Next, I added the official Kubernetes package source for version 1.30 and installed
all the essential tools: kubeadm, kubelet, and kubectl. These tools help me create
and manage the cluster.
Initializing the Kubernetes Cluster:
Using kubeadm init, I started the Kubernetes control plane with a specific IP range
for pods that matches Calico’s network settings. This command sets up the master
node of the cluster.
After the cluster started, I configured my local environment (kubectl) to
communicate with the cluster securely by copying the admin configuration file.
Setting Up Calico Networking:
To enable pod networking, I installed Calico by applying its manifest file. Calico
is a Kubernetes CNI plugin that takes care of network policies and pod-to-pod
communication.
I waited a minute or so to let Calico start running, then checked to make sure all
the system pods were running properly and my single node showed as Ready.
Verifying the Setup:
Finally, I used kubectl get nodes and kubectl get pods -A to make sure the cluster
was healthy, and all pods were running.
Why I Followed These Steps
Kubernetes needs some extra kernel modules and system settings to handle networking
correctly, especially for pods to communicate.
kubeadm makes it easy to bootstrap a Kubernetes cluster by handling complicated
setup under the hood.
Calico is a popular and reliable networking plugin that also provides important
network security controls.
By pinning Kubernetes package versions, I prevent accidental updates that might
break my cluster.
In short:
I prepared my Ubuntu system, installed Kubernetes components, initialized the
cluster with kubeadm, set up Calico networking, and then verified everything was
working. This way, I created a fully functional single-node Kubernetes cluster
where I can run and manage containerized applications.