To set up and install Kubernetes on Ubuntu, you'll need to install Docker (or another container runtime), configure hostnames, disable swap, and install Kubernetes components like `kubeadm`, `kubelet`, and `kubectl`. The process involves initializing the master node with `kubeadm init`, then joining worker nodes to the cluster using the join command generated during initialization

Here's a more detailed breakdown:

1. Prerequisites:

	- **Ubuntu Server:** A clean installation of Ubuntu Server (e.g., 20.04, 22.04, or 24.04) on all nodes (master and worker nodes) is required. 
	
	- **Sufficient Resources:** Ensure each node has enough resources ( 2 CPU, 4GB memory, 50GB disk space) to run Kubernetes and your applications. 


2. Preparation on all Nodes:

- **Update and Upgrade:** Ensure your system is up to date: 
	- `sudo apt update && sudo apt upgrade -y`. 

- **Disable Swap:** Disable swap space for better performance: 
	- `sudo swapoff -a` 
	- `sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

- **Setup certain kubernetes pre-req modules

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

- **Enable IP forwarding:** Enable IPv4 forwarding on all nodes:
	- `sudo sysctl net.ipv4.ip_forward=1` 
	- `sudo tee /etc/sysctl.d/k8s.conf <<EOF net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 EOF`. 

- **Install Containerd:** Install a container runtime like Docker or Containerd. 

	- `sudo apt install -y docker.io`
	- `sudo systemctl start docker
	- `sudo systemctl enable docker

-- **Install Kubernetes Components:** Install `kubeadm`, `kubelet`,

    sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl
    
    sudo curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg
   
	echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | 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
	
	
- **Initialize the Cluster:** On the master node, initialize the cluster using `kubeadm`: 

		sudo kubeadm init --pod-network-cidr=10.0.0.0/16'
	

Configure `kubectl` for the cluster:
	
	sudo mkdir -p $HOME/.kube '

	sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

	sudo chown $(id -u):$(id -g) $HOME/.kube/config

Joining Workers Nodes to the Cluster

	kubeadm token createe --print-join-command

Setup Flannel for kubernetes networking

	wget https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

	nano kube-flannel.yml
**Update the Network Line which is this
	"Network": "10.244.0.0/16",

**Update it to be the CIDR that is used for the initalizing the pod so in this example
	"Network": "10.0.0.0/16",

	kubectl apply -f kube-flannel.yml

Install the Calico Operator:
	kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/tigera-operator.yaml

Apply the Calico Manifest
	kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/custom-resources.yaml