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 -y

3. Disable Swap

On all nodes, disable swap:

sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

4. 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 --system

5. 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

  1. Update and upgrade all nodes.

  2. Disable swap on all nodes.

  3. Configure kernel parameters on all nodes.

  4. Install Containerd runtime on all nodes.

  5. Add Kubernetes repository and install kubelet, kubeadm, and kubectl on all nodes.

  6. Initialize the master node.

  7. Join worker nodes to the cluster.

  8. (Optional) Deploy a test application.

Last updated