K8s — Initiating

Sarthak
CodeX
Published in
2 min read3 days ago

In the previous blog in the series of Kubernetes we talked about its architecture and pods. Let us deep dive into the ocean and see the glacier that is K8s.

We will be conducting a very small practical with the help of AWS and principles of K8s. This will help you grasp the theory that you just read. For this I am assuming you know basics of AWS, such as Instances, VPC’s, Routes, Subnets etc.

  1. Open your AWS Console, Launch 3 instances. One for Master Node, other two for Slave/Worker Nodes
  2. SSH into the master Node and install the K8s on it. After you have installed all the necessary files such as kubectl and kubeadm etc. write the command
kubeadm init 

This will initialize the K8s cluster. After this command you will get a long string starting from “kubeadm join …” copy this command and save it somewhere for future use.

3. Create required directories via

mkdir -p $HOME/.kube

4. Copy configuration to Kube directory

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

5. Provide the necessary permissions to the config file

chown $(id-u):$(id-g)$HOME/.kube/config 

6. Deploy flannel node network for its repository path. Flannel is going to place a binary on each node. Let's discuss more about what Flannel is.

In Kubernetes, Flannel is a popular network fabric that provides an overlay network for pods across multiple nodes in a cluster. It essentially creates a virtual network where each pod gets its own unique IP address, regardless of which physical node it’s running on.

Flannel Node Network:

The “Flannel node network” refers to the subnet assigned to each node in the Kubernetes cluster by Flannel. This subnet is used to allocate IP addresses to the pods running on that specific node.

Key Points about Flannel Node Network:

  • Subnet Allocation
  • Pod IP Addressing
  • Overlay Network: Flannel encapsulates pod network traffic within another protocol (like UDP or VXLAN) to enable communication between pods on different nodes, creating an overlay network on top of the underlying physical network.
  • Routing

Benefits of Flannel Node Network:

  • Pod-to-Pod Communication
  • Scalability
  • Flexibility

Important: While Flannel is a popular choice, it’s not the only network fabric available for Kubernetes. Other options include Calico, Cilium, and Weave Net, each with its own strengths and weaknesses.

sudo kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml

Now Let us come to the worker Nodes

  1. You just have to paste that string that you copied earlier on the both nodes and enter

Hence, Your K8s cluster is ready to use, you can launch the command

sudo kubectl get pods
sudo kubectl get nodes

To check if everything is working fine. Lets cover more concepts and theory in the next blog.

Stay Tuned!

--

--