Setting Up a Kubernetes Cluster with kubeadm on CentOS
A Kubernetes cluster built with kubeadm provides a clear learning path from individual Linux hosts to a working control plane and worker fleet. This guide uses CentOS Stream 9, containerd, kubelet, kubeadm, and kubectl, with commands suitable for a small lab or an early production design.
CentOS 7 is end-of-life, so new deployments should use CentOS Stream 9 or a supported RHEL-compatible distribution. In Australia, a lab might run across Sydney and Melbourne offices, while a production cluster may need careful planning for data residency, Australian Eastern time zones, and connectivity through business NBN or cloud links.
Prepare CentOS hosts
Create at least one control-plane node and one worker node. Give every machine a permanent hostname and address, then make sure each host can resolve the others. Replace the example addresses with values from your network:
hostnamectl set-hostname k8s-control
cat <<'EOF' >> /etc/hosts
192.168.10.10 k8s-control
192.168.10.11 k8s-worker1
192.168.10.12 k8s-worker2
EOF
Update the operating system and install useful utilities. Administrators who need a quick reference for shell syntax can consult these Linux command examples while working through the setup.
dnf update -y
dnf install -y curl wget vim bash-completion chrony
systemctl enable --now chronyd
Kubernetes requires swap to be disabled unless you deliberately configure an alternative supported arrangement. Disable it immediately and prevent it from returning after a reboot:
swapoff -a
sed -i '/ swap / s/^/#/' /etc/fstab
Configure networking and containerd
Load the kernel modules required by container networking and enable IP forwarding. The bridge settings allow Kubernetes traffic to pass correctly through the Linux networking stack:
cat <<'EOF' > /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat <<'EOF' > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
Install containerd and create its default configuration. Kubernetes works best when the runtime uses systemd cgroups, which matches the default control model on modern CentOS:
dnf install -y containerd
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' \
/etc/containerd/config.toml
systemctl enable --now containerd
SELinux should remain enforcing where possible. For a first lab, many administrators temporarily use permissive mode to reduce variables, but production hosts should follow the chosen Kubernetes distribution’s SELinux guidance rather than disabling a security control permanently.
Install Kubernetes packages
Add the Kubernetes RPM repository on every node. The minor version in this example is a placeholder; select one supported by your organisation and use the same repository version throughout the cluster:
cat <<'EOF' > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
EOF
dnf install -y kubelet kubeadm kubectl
dnf mark install kubelet kubeadm kubectl
systemctl enable kubelet
The kubelet may appear inactive until kubeadm init or kubeadm join supplies its configuration. That is expected. Check package versions before proceeding:
kubeadm version
kubectl version --client
containerd --version
If firewalld is enabled, permit the required control-plane and worker ports. Kubernetes networking plugins may require additional ports, so confirm the documentation for the selected CNI:
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10257/tcp
firewall-cmd --permanent --add-port=10259/tcp
firewall-cmd --reload
Bootstrap the control plane
Run initialisation on the control-plane host. The pod network range must match the CNI plugin you intend to install:
kubeadm init \
--apiserver-advertise-address=192.168.10.10 \
--pod-network-cidr=10.244.0.0/16
When the command completes, configure kubectl for the administrator account:
mkdir -p "$HOME"/.kube
cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config
chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config
kubectl get nodes
The node will usually show NotReady until a pod network is installed. For a simple lab using the Flannel network plugin, apply its manifest and then inspect the system pods:
kubectl apply -f \
https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
kubectl get pods -A
For production, evaluate Cilium, Calico, or another maintained CNI against requirements for network policy, observability, encryption, and support. A cluster serving Brisbane users may need different ingress and latency decisions from one serving workloads in Perth.
Join worker nodes
kubeadm init prints a worker join command containing the API server address, token, and discovery hash. Run that command on each worker as root:
kubeadm join 192.168.10.10:6443 \
--token <token> \
--discovery-token-ca-cert-hash sha256:<hash>
If the command was lost, generate a new one on the control plane:
kubeadm token create --print-join-command
Return to the control plane and verify node registration:
kubectl get nodes -o wide
kubectl get pods -A
Workers should eventually report Ready. If they do not, inspect journalctl -u kubelet, confirm time synchronisation, check DNS resolution, and verify that firewalld permits traffic between nodes.
Verify, secure, and operate the cluster
Test scheduling with a small deployment and expose it internally:
kubectl create deployment nginx --image=nginx
kubectl scale deployment nginx --replicas=2
kubectl get deployment,pods
For an Australian business, security planning should account for the Privacy Act 1988, contractual data-location requirements, and controls commonly mapped to the Essential Eight. These obligations do not replace Kubernetes security practices: use RBAC, encrypted secrets, regular patching, audit logging, backups, and restricted API access.
| Area | Lab approach | Production approach |
|---|---|---|
| Control plane | One CentOS host | Multiple control-plane nodes |
| Container runtime | containerd with systemd cgroups | Pinned, tested runtime versions |
| Networking | Flannel or another basic CNI | CNI with policy and monitoring |
| Availability | Local or single-region nodes | Failure domains across suitable zones |
| Access | Admin kubeconfig on one host | RBAC, MFA-aware identity, audited access |
| Data handling | Test data only | Privacy, retention, backup, and residency controls |
Maintain a written record of the Kubernetes minor version, CNI release, firewall rules, node addresses, and backup location. Linuxtpoint’s Linux administration guides provide useful background for the surrounding system-management tasks.
The practical takeaway is simple: standardise every node first, initialise one carefully configured control plane, install a compatible CNI, join workers with a fresh token, and verify each layer before moving to production workloads.