First of all, what is Kubernetes?
Kubernetes (K8s) is an orchestration tool that automates the deployment, scaling, and management of containerized applications. It provides key features like:
- Scaling: Automatically scales applications up or down based on demand.
- Updating: Manages rolling updates and rollbacks to ensure seamless application updates.
- High Availability: Ensures applications run without downtime by distributing containers across multiple nodes.
- Load Balancing: Distributes traffic efficiently to maintain performance.
- Self-Healing: Detects and replaces failed containers automatically.
But to happen this thing initial step is to install it
Below are the steps to achieve it.
#Installing Kubernetes using kubeadm in Ubuntu:
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
#Enable IPv4 packet forwarding
#sysctl params required by setup, params persist across reboots
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
EOF
# Apply sysctl params without reboot
sudo sysctl --system
*#verify it by command as the output should be 1: *
sudo sysctl net.ipv4.ip_forward
#(Althoug it present but if not available) make directory with permission if not present you can check by going to this directory /etc/apt/keyrings
_#sudo mkdir -p -m 755 /etc/apt/keyrings_
#Add the Kubernetes repository
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
#Execute the below command after creating kubernetes repo
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
#As installing k8s version v1.31 no need to install Docker as in k8s instead installing container runtime environment(cri-o, containerd, Docker Engine) it provides the required docker usage stuff
#Add the CRI-O repository:
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
#Then run the created repo:
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/v1.31/deb/ /" | sudo tee /etc/apt/sources.list.d/cri-o.list
#Execute the following command
sudo apt-get update
sudo apt-get install -y cri-o kubelet kubeadm kubectl
#Install the packages
sudo systemctl start crio.service
#This will start the cri-o service
sudo swapoff -a
#as this makes the kubelet not to start
sudo modprobe br_netfilter
#Bootstrap a cluster
sudo kubeadm init
#Below command gets provided by running kubeadm init which need to be performed
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
#Create cni network
curl https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/calico.yaml -O
kubectl apply -f calico.yaml
#last will copy and paste the kubeadm join command into the desired node which will be like given below **
**#example:
sudo sudo kubeadm join 192.168.46.157:6443 --token7xlnp0.9uv4z0qr4wvzhtqn \ --discovery-token-ca-cert-hash sha256:4a1a412d2e682556df0bf10dc380c744a98eb99e8c927fa58eb025d5ff7dc694
Top comments (0)