Skip to content

Instantly share code, notes, and snippets.

@Bharat-B
Created June 6, 2025 13:11
Show Gist options
  • Save Bharat-B/d838446b22747999e1083fc6b717582c to your computer and use it in GitHub Desktop.
Save Bharat-B/d838446b22747999e1083fc6b717582c to your computer and use it in GitHub Desktop.

Kubernetes Cluster Setup with Cilium CNI

This guide provides a step-by-step process to set up a Kubernetes cluster using Cilium as the Container Network Interface (CNI).

Prerequisites

  • Ubuntu/Debian-based system
  • Root or sudo privileges
  • Internet connectivity

Installation Steps

1. System Update and Package Installation

apt-get update -y
apt-get upgrade -y
apt-get install -y apt-transport-https ca-certificates curl

2. Kernel Module Configuration

cat <<EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

modprobe overlay
modprobe br_netfilter

3. Containerd Installation and Configuration

apt-get install -y containerd
mkdir /etc/containerd
containerd config default | tee /etc/containerd/config.toml

Edit /etc/containerd/config.toml to set:

[plugins."io.containerd.grpc.v1.cri".containerd.runtime.runc.options]
SystemdCgroup = true

Ensure this setting is NOT enabled:

[plugins."io.containerd.grpc.v1.cri"]
systemd_cgroup = false

Restart containerd:

service containerd restart

4. Network Configuration

cat <<EOF | tee /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

5. Kubernetes Repository Setup

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/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.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

6. Kubernetes Components Installation

apt update -y
apt install kubeadm kubelet kubectl -y
apt-mark hold kubeadm kubelet kubectl

7. Kubelet Configuration

Add to /etc/default/kubelet:

KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"

Reload and restart:

systemctl daemon-reload && systemctl restart kubelet

8. Cluster Initialization (Master Node)

kubeadm init --pod-network-cidr 10.100.0.0/16

Configure kubectl:

mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

9. Worker Node Joining

On worker nodes, run the join command provided by kubeadm init output.

Cilium CNI Installation

1. Cilium CLI Installation

CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
CLI_ARCH=amd64
if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}

2. Cilium Installation

cilium install --version 1.17.4

3. Verification

cilium status --wait

Notes

  • For production environments, consider using specific versions of Kubernetes and Cilium that are known to be compatible
  • Ensure all nodes meet the minimum system requirements
  • The pod network CIDR (10.100.0.0/16) should not conflict with your existing network infrastructure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment