User-defined Playground
 by Márk Sági-Kazár

kubeadm Playground

A single-machine playground to experiment with kubeadm, a tool built to provide best-practice "fast paths" for creating Kubernetes clusters.

Playground Parameters

kubeadm playground: A single-machine playground to experiment with kubeadm,
a tool built to provide best-practice "fast paths" for creating Kubernetes clusters.

This is a single-machine playground. A multi-machine playground for larger and HA clusters is WIP.

🔧 System Components

  • kubelet: The primary node agent that runs on each node
  • Container Runtimes:
    • containerd: Lightweight container runtime (recommended)
    • CRI-O: Lightweight container runtime for Kubernetes
  • Networking:
    • CNI plugins: Container Network Interface plugins
    • Flannel: Network overlay for pod-to-pod communication
    • Canal: Calico for network policy and Flannel

🛠️ Tools

  • kubeadm: Cluster lifecycle management and bootstrapping
  • kubectl (alias: k): Kubernetes cluster management and debugging
  • nerdctl: Docker-compatible CLI for containerd
  • krew: kubectl plugin manager for extending functionality

🎯 Getting Started

Quick Setup

If you want to quickly set up a working cluster, use the automated script:

/opt/playground/init.sh --remove-taint

⚠️ When none is selected as the network addon, the initialization script will skip installing any CNI plugin.

This script performs all the steps below automatically. Continue reading to understand what happens under the hood.

Manual Setup (Step-by-Step)

1. Initialize the Cluster

sudo kubeadm init --pod-network-cidr=10.244.0.0/16

2. Configure kubectl Access

# Set up kubectl for the current user
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# Verify cluster access
kubectl cluster-info
kubectl get nodes

3. Install a Network Addon

Flannel
Canal
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

# Wait for all pods to be ready
kubectl wait --for=condition=Ready pods --all -n kube-flannel --timeout=300s
calicoVersion=$(curl -s https://api.github.com/repos/projectcalico/calico/releases/latest | jq -r .tag_name)
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/${calicoVersion}/manifests/canal.yaml

# Wait for all pods to be ready
kubectl wait --for=condition=Ready pods --all -n kube-system --timeout=300s

4. Allow Scheduling on Control Plane

# Remove taint to allow pods on control plane node
kubectl taint nodes --all node-role.kubernetes.io/control-plane-

# Verify node is ready and schedulable
kubectl get nodes

Verify Your Cluster

# Check all system pods are running
kubectl get pods --all-namespaces

# Deploy a test application
kubectl create deployment podinfo --image=ghcr.io/stefanprodan/podinfo --port=9898
kubectl expose deployment podinfo --port=9898 --type=NodePort

# Check the deployment
kubectl get pods,services

Resetting the Cluster

The easiest way to reset the cluster is terminating the playground and starting a new one.

That being said, it's a good idea to learn how to reset the cluster manually.

First, reset the cluster itself using kubeadm:

kubeadm reset -f

Stop kubelet:

systemctl stop kubelet

Then cleanup any CNI config created by the network addon you installed:

rm -rf /etc/cni/net.d/*.conflist

Delete any CNI interfaces created by the network addon:

ip link delete cni0

# For flannel
ip link delete flannel.1

📚 Learn More

🧪 Playgrounds

Happy learning! 🚀