it's the simplest way to install Kubernetes on your VM, that i've used to install my Cluster. it
took me 8 hours to research and install it.
Prerequisites
A single VM with Ubuntu installed
A Domain (not required but recommended)
Creating a Cluster ready machine.
Step 1: Make sure you have a freshly installed VM.
if you dont, you might face some errors. i had those issues and i decided to do it on a fresh VM.
Step 2: Update your repositories and packages
sudo apt update && sudo apt upgrade -y
Step 3: Disable swap and enable some kernel configurations
# this will disable swapsudo swapoff -a# this will comment out the swap line in the fstab filesudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
these kernel configurations are required for Kubernetes to work properly.
# this will enable overlay and br_netfiltersudo tee /etc/modules-load.d/containerd.conf <<EOFoverlaybr_netfilterEOF# here we are loading the modulessudo modprobe overlaysudo modprobe br_netfilter# this will enable some kernel configurationssudo tee /etc/sysctl.d/kubernetes.conf <<EOFnet.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1net.ipv4.ip_forward = 1net.ipv4.ip_unprivileged_port_start=0EOF# this will apply the changessudo sysctl --system
net.ipv4.ip_unprivileged_port_start=0 seems to be important to use traefik. otherwise you'll get
bind to:80/443 error.
when i was trying to configure my Cluster, i faced this issue. that traefik was failing to bind to
:80/443.
i had to set net.ipv4.ip_unprivileged_port_start=0 and then, everything worked fine.
Step 4: Add the required repositories
always update your repositories and install the required packages.
sudo apt update -y
then install curl, software-properties-common, apt-transport-https, and ca-certificates.
Step 4: Wait for the nodes to be ready (you have to wait for network pods to be ready)
watch kubectl get nodes -A
Congratulations! you've created your first Kubernetes cluster.
if you want to add more nodes (it should always be an odd number), you have to repeat the
initialization process on the new node. and then use the join command that we created earlier. to
join the new node to the cluster.
Install helm, ingress, and other tools
Step 1: Install helm
i'd like to install helm using apt. you can do it how ever you want.
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/nullecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
then update the package manager
sudo apt update
then install helm
sudo apt install helm
Step 2: Install ingress
i'd like to use traefik for the ingress. you can use any other ingress controller if you want. like
nginx, etc.