Skip to content

mialeevs/kubernetes_installation_crio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Installation on Ubuntu 22.04

Get the detailed information about the installation from the below-mentioned websites of cri-o and Kubernetes.

cri-o

Kubernetes

Set up the cri-o and Kubernetes repositories:

Download and install the necessary tools for Cri-o

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

# Export the OS and CRI_O version values
export OS_VERSION=xUbuntu_22.04
export CRIO_VERSION=1.28

Download the GPG key for cri-o

sudo curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS_VERSION/Release.key | sudo gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg

sudo curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS_VERSION/Release.key | sudo gpg --dearmor -o /usr/share/keyrings/libcontainers-crio-archive-keyring.gpg

Add the cri-o repository

# we can get the latest release details from https://cri-o.io/

sudo echo "deb [signed-by=/usr/share/keyrings/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS_VERSION/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list

sudo echo "deb [signed-by=/usr/share/keyrings/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS_VERSION/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list

Add the GPG key for kubernetes

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Add the kubernetes repository

Check for the latest release in https://packages.cloud.google.com/apt/dists

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

Update the repository

# Update the repositiries
sudo apt-get update

Install cri-o and Kubernetes packages.

Note that if you want to use a newer version of Kubernetes, change the version installed for kubelet, kubeadm, and kubectl and be sure that all three use the same version. These version should support the cri-o version.

# Use the same versions to avoid issues with the installation.
sudo apt-get install -y cri-o cri-o-runc cri-tools kubelet kubeadm kubectl
# Start the cri-o service
sudo systemctl daemon-reload
sudo systemctl enable crio
sudo systemctl start crio

To hold the versions so that the versions will not get accidently upgraded.

sudo apt-mark hold cri-o kubelet kubeadm kubectl

Enable the iptables bridge

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

sudo modprobe overlay
sudo modprobe br_netfilter

# sysctl params required by setup, params persist across reboots
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

# Apply sysctl params without reboot
sudo sysctl --system

Disable SWAP

Disable swap on controlplane and dataplane nodes

sudo swappff -a
sudo vim /etc/fstab
# comment the line which starts with **swap.img**.

On the Kube master server

Initialize the cluster by passing the cidr value.

Use Calico

# Calico network
# Make sure to copy and backup the join command
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --cri-socket unix:///var/run/crio/crio.sock

# Copy your join command and keep it safe.
# Below is a sample
kubeadm join 10.128.0.2:6443 --token swi0ci.jq9l75eg8lvpxz6g --discovery-token-ca-cert-hash sha256:2c3cdfa898334b0dfc0f73bbccb998d03f61252ee50f0405c85ba735ff90b4d1

To start using the cluster with 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

To set up the Calico network

# Use this if you have initialised the cluster with Calico network add on.
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/tigera-operator.yaml

curl https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/custom-resources.yaml -O


kubectl create -f custom-resources.yaml

Check the nodes

# Check the status on the master node.
kubectl get nodes

On each of Kube node server

Joining the node to the cluster:

sudo kubeadm join $controller_private_ip:6443 --token $token --discovery-token-ca-cert-hash $hash

TIP

If the joining code is lost, it can retrieve using below command

kubeadm token create --print-join-command

To install the metrics server

git clone https://github.com/mialeevs/kubernetes_installation_crio.git
cd kubernetes_installation_crio/
kubectl apply -f metrics-server.yaml
cd
rm -rf kubernetes_installation_crio/

About

Kubernetes installation using CRI-O as container engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors