Logo

dev-resources.site

for different kinds of informations.

Setting Up a Kubernetes With CRIO (I)

Published at
12/29/2024
Categories
Author
Zahid Ahmed
Categories
1 categories in total
open
Setting Up a Kubernetes With CRIO (I)

1. Setting Hostnames (Master & Worker Nodes)

sudo hostnamectl set-hostname "master-one.k8s.local"
sudo init 6

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

3. Disabling Swap (Master & Worker Nodes)

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

4. Configure Modules (Master & Worker Nodes)

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

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
sudo sysctl --system
sysctl net.ipv4.ip_forward
sysctl -w net.ipv4.ip_forward=1

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
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo systemctl enable kubelet

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

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

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

9. Check Cluster Status (Master Node Only)

kubectl cluster-info

Featured ones: