Setting up a kubeadm-based Kubernetes cluster.

Prerequisites:

Server :

3 ubuntu nodes

Masternode:

min 2cpu 2GB RAM ( t2.medium)

Worker node:

min 1cpu 2GB RAM (t2.small)

server network

10.X.X.X or 172.X.X.X

pod network

  1. X.X.X

here I have used 3 elastic IP addresses (static IPs)

Created a Security group with the following ports for the master and worker nodes.

In the Master node, we need to allow the following ports for inbound incoming traffic

TCP inbound 6443 - Kubernetes API Server TCP inbound 2379-2380 - etcd server client API TCP inbound 10250 -kubelet API TCP inbound 10251 -kubescheduler TCP inbound 10252 -kube control manager

In the Worker node, we need to allow the following ports for inbound traffic

TCP inbound 10250 - kubelet API TCP inbound 3000-32767 - NodePortservice

Routing/Firewall Routing rule enables for all CIDR ranges

OR

Security Group

TCP Inbound 22 for SSH to 0.0.0.0/0 All Traffic to 0.0.0.0/0

Step 2:

I have kept kubeadm-scripts in GitHub repository

GIT Repository for installation scripts:

$ git clone https://github.com/techiescamp/kubeadm-scripts

GitHub repo contains

  1. scripts

  2. manifests

  3. terraform/aws provider

Kubernetes Cluster Setup Using Kubeadm (Self-hosted Kubernetes cluster )

Change hostname

sudo hostnamectl set-hostname k8s-master-1

Following are the high-level steps involved in setting up a kubeadm-based Kubernetes cluster.

  1. Install container runtime on all nodes- We will be using cri-o.

  2. 2. Install Kubeadm, Kubelet, and kubectl on all the nodes. 3. Initiate Kubeadm control plane configuration on the master node.

$ sudo kubeadm init
  1. Save the node join command with the token.

     $ kubeadm join 44.199.148.255:6443 --token 5q315j.qhbhd9z3dw7v66ql --discovery-token-ca-cert-hash sha256:7c58a4d8b7614cbbe80f473c3226d4fcf480030b34d9093c7bfdfa14d5a08743 --control-plane
    
  2. Install the Calico network plugin (operator).

  3. Join the worker node to the master node (control plane) using the join command.

$ kubeadm token create --print-join-command
  1. Validate all cluster components and nodes

     $ kubectl get po -n kube-system
    
$ kubectl get nodes

$ kubectl label node k8s-worker-2 node-role.kubernetes.io/worker=worker

$ kubectl get po -n kube-system

  1. Install Kubernetes Metrics Server

$ kubectl apply -f https://raw.githubusercontent.com/techiescamp/kubeadm-scripts/main/manifests/metrics-server.yaml

kubectl top nodes

Now, cluster is ready to deploy application

  1. Deploy a sample app and validate the app

Did you find this article valuable?

Support Vishvanath Patil by becoming a sponsor. Any amount is appreciated!