Kubernetes For beginners

Kubernetes For beginners

  • Some Back Story

  • Configuration Management

    • This basically means you can maintain all the changes in your infrastructure with the help of a software
    • e.g. Ansible etc
    • Previously it was mutable ( like you can make the changes to your servers that were running) before virtual machines
    • When VMs came they became immutable (You cannot change that is already running )
      • Therefore it offers some reliability as compared to before VMs scenerio
      • It is better in terms of security & stuff
  • Lets talk about how applications were structured in previous days
  • Monolithic Applications

    • Lets suppose we have a website which has Frontend, Backend, Chat messages, DB, Networking component
    • In This example we have 5 components in a single webapp.
    • If You bundle this as a single application
      • Here bundle means Deploying it as one application in the container
      • This is Known as Monolithic application
    • Now The problem with monolithic application is that since it is deployed as a one complete bundle so suppose if you wanna make changes in DB you would have to deploy everything entirely , which is not a very good design to have
  • Present scenario

  • Micro-services

    • We solved the problem of monolithic applications by implementing Microservices. Now basically the idea is that instead of deploying the whole app as a single application all of those components are deployed as individual applications
      • i.e. Frontend, Backend, DB, chat messaging , networking component are deployed separately
    • We can use containers and run the microservices inside containers
    • Fault isolation: You can make changes in one application without affecting the other applications
  • Orchestration

    • Orchestrations help us in deploying and managing applications dynamically
    • Kubernetes does orchestration
    • Remember: Kubernetes is much more than a container orchestrator
  • Difference between Docker and Kubernetes

    • Docker is a container tool and Kubernetes acts as an orchestrator
  • Architecture of Kubernetes

  • K8s cluster
    • It basically means that you have your own bunch of Nodes and Control Plane (i.e. Nodes + Control plane)
      • Node : Can be treated as a virtual machine
      • Control plane : Previously known as master node
    • image.png
  • Kubectl :
    • It is the Command Line tool
    • Kubectl communicates with the control plane
      • Like => hey control plane, I want to start 10 application. Control plane => Okay, let me see which which node is empty and can handle the load, I will redirect your containers over there
  • Pod
    • It is a scheduling unit in K8s
  • Steps for running applications in K8s

  • 1) You will need web Application => create microservice
  • 2) Add every microservice in its container
    • i.e. Containerization
  • 3) Put every container in pods
  • 4) Deploy these pods
  • Control Plane

  • It is a collection of various components that helps us in managing the overall health of the cluster
    • API Server
      • All the Communication that will take place will happen via API server
    • etcd
      • It's a Database, it basically stores information about the cluster
    • Controller manager
      • It has 4 functionalities
        • 1) Check the desired state
        • 2) Manage the current state
        • 3) Differneces
        • 4) Make the changes
    • Scheduler
      • It is responsible for physically scheduling the objects & stuffs
  • Inside Worker Node

  • Kubelet
    • Kubelet is very important
    • It's on every worker node
    • So whenever new worker node is created and attached to the control plane the Kubelet is installed on them
    • Its job is to listen to API server
  • Kube-proxy
    • It is something that is responsible for networking
    • If your cluster wants to communicate with outside world, kube-proxy will help in doing that
    • Kube-proxy will make sure that every worker node & stuff that you have will get its own unique IP address
  • K8s DNS

  • K8s has its own internal DNS.
  • SO it basically has IP addresses for every pod and all containers . Pods can communicate with each other