Setting Up Kubernetes: A Step-by-Step Guide

Setting Up Kubernetes: A Step-by-Step Guide

In the previous blog we saw the basic definition of kubernetes. In this blog, we’ll explore the steps involved in setting up a Kubernetes environment, installing it, and configuring cluster networking.

Preparing the Environment

To run kubernetes we need below hardware and software prerequisites.

Hardware Prerequisites:

– A minimum of two machines. One will act as the master (control plane node), and the others will act as workers (worker nodes).

– 2 GB or more of RAM for the master and 1 GB or more for the workers.

– 2 CPUs or more on the master.

Software Prerequisites:

– A compatible Linux OS (e.g., Ubuntu 18.04 or later).

– SSH access to all machines.

– User with sudo privileges.


1. Update the System

   On all nodes, update your system packages:  


2. Install Docker

   Kubernetes requires Docker to run containers:  


3. Disable Swap

   Kubernetes does not support swap memory, so it needs to be disabled:



Installing Kubernetes

1. Install Kubernetes Tools

   On all nodes, install `kubelet`, `kubeadm`, and `kubectl`:


2. Initialize the Master Node

   On the master node:

This command initializes the master node and provides a command to join worker nodes to the cluster. Take note of this command.


3. Set Up Local kubeconfig

   To use `kubectl` as a non-root user:


4. Join Worker Nodes

On each worker node, run the command provided after the master initialization (it’ll look something like `kubeadm join …`). This will join them to the master.


Configuring Cluster Networking

Kubernetes requires a Pod Network to allow pods to communicate with each other. One popular solution is Flannel.

1. Install Flannel Networking

   On the master node:


2. Verify Installation

   After a few moments, all nodes should be in the `READY` state when you run:


And you should see the flannel pods running when you execute:

kubectl get pods –all-namespaces


Setting up Kubernetes may seem complex, but with the right guidance, it becomes manageable. In this guide, we’ve covered the essential steps, from environment preparation to cluster networking configuration. Kubernetes empowers you to manage containerized applications at scale, and with your cluster up and running, you’re ready to start deploying and orchestrating your container workloads.