What is Kubernetes? Know About Architecture, Components and Setup

Table of Contents

    What is Kubernetes ?

     
    ●  Kubernetes is an orchestration engine and open-source platform for managing containerized applications.
    ●  Automated rollout and rollback, if their many versions (like 1,2,3,4,,,,,.). In Kubernetes, we can go to previous versions whichever we want.
    ●  Responsibilities include container deployment, scaling & descaling of containers & container load balancing.
    ●  Kubernetes Supports Autoscaling and Dynamic Scaling.
    ●  Actually, Kubernetes is not a replacement for Docker, But Kubernetes can be considered as a replacement for Docker Swarm, Kubernetes is significantly more complex than Swarm, and requires more work to deploy.
    ●  Born in Google, written in Go/Golang. Donated to CNCF(Cloud-native computing foundation) in 2014.
    ●  Kubernetes v1.0 was released on July 21, 2015.
    ●  Current stable release v1.23.0.
     

    Kubernetes Architecture

    Kubernetes implements a cluster computing background everything works from inside a Kubernetes Cluster, This cluster is hosted by one node acting as the ‘Master’ of the cluster, The other nodes as ‘nodes(Worker Nodes)’ which do the actual ‘Containerization’. Below is a diagram showing the same.
     
     

    Kubernetes Components:

     
    Web UI (Dashboard)
    The dashboard is a web-based Kubernetes user interface. You can use Dashboard to deploy containerized applications to a Kubernetes cluster, troubleshoot your containerized application, and manage the cluster itself along with its available resources.
    Kubectl
    Kubectl is a command-line configuration tool (CLI) for Kubernetes used to interact with a master node of Kubernetes. Kubectl has a config file called kubeconfig. This file has the information about the server and authentication information to access the API Server.


    Master Node

    ● The master node is responsible for the management of the Kubernetes cluster
    API Server:- Kube API Server interacts with API, its frontend of the Kubernetes cluster plane. 
    Scheduler:- Scheduler watches the pods and assigns the pods to run on specific hosts.
    Controller Manager:- Controller manager runs the controllers in the background which runs different tasks in the Kubernetes cluster, performs cluster-level functions (replication, keeping track of worker nodes, handling nodes failures…).
    Etcd:- Kubernetes uses etcd as its database to store all cluster data. 
     

    Worker Nodes 

    Worker nodes are the nodes where the application is actually running in the Kubernetes cluster, Each worker node are controlled by the master node using a kubelet process.
    Kubelet:- Kubelet is the primary node agent that runs on each node and reads the container manifests which ensures that containers are running and healthy. 
    Kube-proxy:-  It helps us to have a network proxy and load balancer for the services in a single worker node. Worker nodes can be exposed to the internet via Kube proxy. 


    Installation 

    Different ways to install Kubernetes
    ● GCP - Google Kubernetes Engine (GKE)
    ● AWS - Amazon EKS
    ● Azure - Azure Kubernetes Services (AKS)
    ● Minikube → Using Minikube we can setup single node K8s cluster, 
    kubeadm → we can setup multi-node k8s cluster
    KOPS → Kubernetes operations, it is a software using which we can set up  highly available Kubernetes clusters in AWS
     
     

    Kubernetes Setup Using Kubeadm In AWS EC2 Ubuntu Servers

     
    Prerequisite:
    =============
    2 - Ubuntu Serves (Minimum Required)
     
    1 - Manager  (4GB RAM , 2 Core) t2.medium 
    1 - Workers  (1 GB RAM, 1 Core) t2.micro
     
    Open Required Ports In AWS Security Groups.
     

    # After launching the Two instances try to connect through Mobaxterm or Putty or Powershell etc,,,

     
    1. Master Node                                                      
    2. Worker Node
     

    Then we will try to setup some required packages

     
    # First, login as ‘root’ user because the following set of commands need to be executed with ‘sudo’ permissions.
     
    sudo su -
     
    # Install Required packages and apt keys.
     
    apt-get update -y
    apt-get install -y apt-transport-https
     
    # Above command helps you to download through Internet Secure Protocol
     
    # Adding GPG Key
     
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb https://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    apt-get update -y
     
    #Turn Off Swap Space
     
    swapoff -a
    sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
     
    # Installing Docker
    apt install docker.io -y
    usermod -aG docker ubuntu
     
    # Restart docker with the following command
    systemctl restart docker
     
    # Enable docker service, it is done with the following command
    systemctl enable docker.service
     
    # update the existing packages
    apt-get update
     
    # Install the Kubelet, Kubeadm, and Kubectl
    apt-get install -y kubelet kubeadm kubectl
     
    # Now reload daemon
    systemctl daemon-reload
     
    # Start kubelet, this can be done with the help of the following command
    systemctl start kubelet
     
    # Enable kubelet service, this can be done with the help of the following command
    systemctl enable kubelet.service
     
    ==========COMMON FOR MASTER & SLAVES END=====
    ===========In Master Node Start====================
     
    # Steps Only For Kubernetes Master
     
    # Switch to the root user.
     
    sudo su -
     
    # Initialize Kubernetes master by executing below command.
    kubeadm init
     
    # It is clear that the Kubernetes master has successfully initialized. Now to use this cluster please run the above three commands mentioned
     
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
     
    # To verify, if kubectl is working or not, run the following command.
    kubectl get pods -o wide –all-namespaces
     
    # You will notice from the previous command, that all the pods are running except one: ‘core-dns’. For resolving this we will install a # pod network. To install the weave pod network, run the following command:
    kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    kubectl get nodes
    kubectl get pods --all-namespaces
     
     
     

    # Get token

    kubeadm token create --print-join-command

    =========In Master Node End====================

    Add Worker Machines to Kubernetes Master

    =========================================

    Copy kubeadm join token from and execute in Worker Nodes to join to cluster
     

     
    kubectl commands have to be executed in the master machine.
     
    Check Nodes
    =============
    kubectl get nodes
     
     

    ADVANTAGES AND DISADVANTAGES OF KUBERNETES


    Advantages:

    ● Automated scheduling.
    ● Self-healing capabilities.
    ● Automated rollouts and rollbacks.
    ● Load balancing and horizontal scale.
    ● Easy organization of the service with pods.
    ● Developed by Google, with extensive experience in the cloud industry.
    ● Kubernetes offers better flexibility even in complex applications.
     

    Disadvantages:

    ● More complex migrations.
    ● Incompatible with existing Docker tools.
    ● Implementing a manual cluster is complicated.
    ● Very complex to install Kubernetes clusters
     

    Kubernetes Objects 

    The basic Kubernetes objects include
    ● Pod 
    ● Replication Controller 
    ● ReplicaSet 
    ● DaemonSet 
    ● Deployment 
     

    What is a Namespace? 

    You can think of a Namespace as a virtual cluster inside your Kubernetes cluster. You can have multiple namespaces inside a single Kubernetes cluster, and they are all logically isolated from each other. They can help you and your teams with organization, security, and even performance. 
     
    The namespaces created in a cluster are always defaulted, kube-system, kube-public, kube-node-lease. 
     

    POD 

    ● A Pod always runs on a Node. 
    ● A pod is the smallest building block or basic unit of scheduling in Kubernetes. 
    ● In a Kubernetes cluster, a pod represents a running process. 
    ● Inside a pod, you can have one or more containers. Those containers all share a unique network IP, storage, network and any other specification applied to the pod. 
    Replication Controller 
    ● A Replication Controller is a structure that enables you to easily create multiple pods, then make sure that that number of pods always exists. If a pod does crash, the Replication Controller replaces it. 
    ReplicaSet 
    ● ReplicaSet is the next-generation Replication Controller. 
    ● The only difference between a ReplicaSet and a Replication Controller right now is the selector support. 
    ● Replication controller supports only Equality based selector &  Replica set supports equality-based & set based selectors.
    DaemonSet 
    ● A DaemonSet we can’t able to Scale Up & Scale Down, if we want each and every Node want to run our pod we can use DaemonSet.
    ● When a new node added to the cluster, a pod is added to it the match the rest of the nodes and when a node is removed from the cluster, the pod is garbage collected.
    Deployment 
    ● In Kubernetes, Deployment is the recommended way to deploy Pod or RS, The advanced features it comes with.
     

    Deployment Strategies 

    There are different types of deployment strategies you can take advantage of depending on your goal. 
    Rolling Deployment 
    ● The rolling deployment is the standard default deployment to Kubernetes. It works slowly, one by one, replacing pods of the previous version of your application with pods of the new version without any cluster downtime.
     

    Recreate 

    ● In this type of very simple deployment, all of the old pods are killed all at once and get replaced all at once with the new ones.
     
     

    Blue/ Green (or Red / Black) deployments 

    ● In a blue/green deployment strategy (sometimes referred to as red/black) the old version of the application (green) and the new version (blue) get deployed at the same time. When both of these are deployed, users only have access to the green; whereas, the blue is available to your QA team for test automation on a separate service or via direct port-forwarding. 
    ● After the new version has been tested and is signed off for release, the service is switched to the blue version with the old green version being scaled down
     
     

    Service

    ●      A service is responsible for making our Pods discoverable inside the network or exposing them to the internet. A Service identifies Pods by its LabelSelector.

    Types of services available:

    ClusterIP – Exposes the service on a cluster-internal IP. Service is only reachable from within the cluster.

     

    NodePort – Exposes the service on each Node’s IP at a static port. Service is reachable from outside the cluster (internet).

     

    LoadBalancer – Exposes the service externally using a cloud provider’s load balancer. NodePort and ClusterIP services, to which the external load balancer will route, are automatically created.

     
    Ingress – Kubernetes Ingress is a resource to add rules for routing traffic from external sources to the services in the Kubernetes cluster.
     

    Let's Connect with Manektech for the Kubernetes Development and Hire Dedicated web developers from India.

    About Author

    Manektech Team

    Nikhil Solanki

    Mobile Lead

    Nikhil Solanki has 10+ years of experience in Mobile App Development and currently works as the Mobile Lead at ManekTechworked. He is an experienced Mobile lead with a demonstrated history of working in Mobile's information technology and services industry. 

    Subscribe to Our Newsletter!

    Join us to stay updated with our latest blog updates, marketing tips, service tips, trends, news and announcements!

    OUR OFFICES


    ManekTech's Global Presence

    USA

    4100 NW Loop 410, Suite 200, San Antonio, Texas, USA 78229

    UK

    7 Artisan Place Harrow, HA3 5DS

    India

    4th Floor, Timber Point, Prahaladnagar Road, Ahmedabad, Gujarat - 380015

    Germany

    Franz-Joseph-Strasse, 11,Munich, 80801, Germany

    South Africa

    The Business Centre No 1. Bridgeway Road, Bridgeway Precint, Century City, Cape Town, South Africa, 7446

    PREV
    NEXT