Install K8s Master/Worker
Step-by-Step Instructions to Install Kubernetes
1. Prerequisites
Ensure you are using Ubuntu (tested on Ubuntu 18.04/20.04).
You need root or sudo access on all nodes.
2. Update and Upgrade the System
On all nodes (master and workers), update and upgrade the system:
sudo apt update
sudo apt upgrade -y3. Disable Swap
On all nodes, disable swap:
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab4. Configure Kernel Parameters
On all nodes, load necessary kernel modules and configure sysctl:
sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
sudo tee /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sudo sysctl --system5. Install Containerd Runtime
On all nodes, install Containerd:
6. Add Kubernetes Repository and Install Components
On all nodes, add the Kubernetes repository and install kubelet, kubeadm, and kubectl:
7. Initialize the Master Node
On the master node, initialize the Kubernetes cluster:
Set up kubeconfig for the current user:
Install the Calico network plugin:
8. Join Worker Nodes to the Cluster
On each worker node, run the kubeadm join command provided by the master node during initialization. Replace <master-node-ip>, <port>, <token>, and <hash> with the actual values:
9. Deploy a Test Application (Optional)
To deploy a test application (e.g., nginx) on the master node:
Summary
Update and upgrade all nodes.
Disable swap on all nodes.
Configure kernel parameters on all nodes.
Install Containerd runtime on all nodes.
Add Kubernetes repository and install kubelet, kubeadm, and kubectl on all nodes.
Initialize the master node.
Join worker nodes to the cluster.
(Optional) Deploy a test application.
Last updated