Kubernetes Operations Documents

This Weblog Just Created For Kubernetes Operations Challenges

Create Lab from scratch on ubuntu 22.04

Step 1: Download ubuntu linux 22.04

Download ubuntu 22.04 from following repository:
Ubuntu Linux download repository

Step 2: Install dependencies

Install following dependencies:

apt install
apt install -y vim

Step 3: Disable firewall

Disable firewall:

ufw disable

Step 4: Disable apparmor

Disable apparmor:

systemctl stop apparmor
systemctl disable apparmor
systemctl mask apparmor

Step 5: Update system packages

Update system packages with following command:

apt update
apt upgrade

Install requirements with following command:

sudo apt install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Step 6: Install latest version of docker

Add docker repository to server package repository:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install docker packages:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Enable and start docker service with following commands:

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

Step 7: Pull images for required hands-on lab

docker pull hello-world
docker pull ubuntu
docker pull nginx
docker pull php:7-apache

Step 8: Configuring Docker for kubernetes installation

cat <<EOF | sudo tee /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF
systemctl restart docker

Step 9: Configuring System for kubernetes installation

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

sudo modprobe overlay
sudo modprobe br_netfilter
cat << EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
fs.file-max = 1500000
fs.nr_open = 1500000

vm.max_map_count = 262144
net.ipv4.ip_local_reserved_ports = 30000-32767

net.ipv4.ip_local_port_range = 1024 65535

net.netfilter.nf_conntrack_max = 32768000
vm.swappiness = 0
net.ipv4.ip_forward = 1
EOF
sysctl --system

Disable swap

swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
# remove swap from /etc/fstab
# make sure swap in lvm mode removed from grub

Step 10: Install kubernetes

Add kubernetes repository to system repository:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt update

Install kubernetes packages:

sudo apt install -y kubelet=1.23.15-00 kubeadm=1.23.15-00 kubectl=1.23.15-00
sudo apt-mark hold kubelet kubeadm kubectl

Enable kubernetes service:

systemctl enable kubelet

Pull kubernetes required container images:

kubeadm config --kubernetes-version 1.23.15 images pull
docker pull docker.io/calico/kube-controllers:v3.24.5
docker pull docker.io/calico/node:v3.24.5
docker pull docker.io/calico/cni:v3.24.5

Download required manifest:

curl https://raw.githubusercontent.com/projectcalico/calico/v3.24.5/manifests/calico.yaml -O
Last updated on 11 Dec 2022
Published on 11 Dec 2022