DEV Community

Cover image for Setting Up a Kubernetes With CRIO (I)
Zahid Ahmed
Zahid Ahmed

Posted on

Setting Up a Kubernetes With CRIO (I)

1. Setting Hostnames (Master & Worker Nodes)


sudo hostnamectl set-hostname "master-one.k8s.local"
Enter fullscreen mode Exit fullscreen mode
sudo init 6
Enter fullscreen mode Exit fullscreen mode

2. Update Hostfile


sudo nano /etc/hosts
#Add the following list in the end of line
172.16.1.100 master-one.k8s.local
172.16.1.101 worker-one.k8s.local
172.16.1.102 worker-two.k8s.local
Enter fullscreen mode Exit fullscreen mode

3. Disabling Swap (Master & Worker Nodes)


sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
Enter fullscreen mode Exit fullscreen mode
sudo swapoff -a
Enter fullscreen mode Exit fullscreen mode

4. Configure Modules (Master & Worker Nodes)


cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
Enter fullscreen mode Exit fullscreen mode
sudo modprobe br_netfilter
sudo modprobe overlay
Enter fullscreen mode Exit fullscreen mode

5. Configure Networking (Master & Worker Nodes)


cat <<EOF | sudo 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
Enter fullscreen mode Exit fullscreen mode
sudo sysctl --system
sysctl net.ipv4.ip_forward
sysctl -w net.ipv4.ip_forward=1
Enter fullscreen mode Exit fullscreen mode

6. Install Kubernetes Management Tools (Master & Worker Nodes)


sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/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.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
Enter fullscreen mode Exit fullscreen mode
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo systemctl enable kubelet
Enter fullscreen mode Exit fullscreen mode

7. Install Container runtime (Master & Worker Nodes)


CRIO_VERSION=v1.31

mkdir -p /etc/apt/keyrings/

apt-get update
apt-get install -y software-properties-common curl
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/$CRIO_VERSION/deb/Release.key | \
    gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg

echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/$CRIO_VERSION/deb/ /" | \
    tee /etc/apt/sources.list.d/cri-o.list

apt-get update
apt-get install -y cri-o
systemctl start crio.service
sudo systemctl status crio
sudo systemctl daemon-reload
sudo systemctl enable crio --now
Enter fullscreen mode Exit fullscreen mode

8. Initialization Kubernetes Cluster (Master Node Only)


sudo kubeadm init \
  --pod-network-cidr=10.10.0.0/16 \
  --upload-certs \
  --control-plane-endpoint=master-one.k8s.local
Enter fullscreen mode Exit fullscreen mode

8. Install Cilium Within Kubernetes Cluster (Master Node Only)


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}
cilium version
cilium install --version 1.16.2
kubectl get pod -n kube-system
Enter fullscreen mode Exit fullscreen mode

9. Check Cluster Status (Master Node Only)


kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

Top comments (0)