What is Kubernetes
Kubernetes is an open source orchestration tool developed by Google for managing microservices or containerized applications across a distributed cluster of nodes.
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.
It has a large, rapidly growing ecosystem.
Kubernetes services, support, and tools are widely available.
Kubernetes is a popular container orchestration tool similar to docker swarm, K8 is mostly used to manage the containers, it is also used for blue-green deployments, also use to scale the containers.
Kubernetes provides highly resilient infrastructure with zero downtime deployment capabilities, automatic rollback, scaling, and self-healing of containers (which consists of auto-placement, auto-restart, auto-replication, and scaling of containers on the basis of CPU usage).
Kubernetes also known as K8s, is an open-source Container Management tool
It provides a container runtime, container orchestration, container-centric infrastructure orchestration, self-healing mechanisms, service discovery, load balancing and container (de)scaling.
Initially developed by Google, for managing containerized applications in a clustered environment but later donated to CNCF
Written in Golang
It is a platform designed to completely manage the life cycle of containerized applications and services using methods that provide predictability, scalability, and high availability.
Kubernetes architecture overview
- K8 nodes are divided into 2 types, master node(control plane), and worker node
- These nodes can be a physical machines as well as the virtual machines
- Master and Worker nodes have different components resided inside it
- Master is responsible for managing the complete cluster.
- You can access master node via the CLI, GUI, or API.
- The master watches over the nodes in the cluster and is responsible for the actual orchestration of containers on the worker nodes.
- For achieving fault tolerance, there can be more than one master node in the cluster.
- It is the access point from which administrators and other users interact with the cluster to manage the scheduling and deployment of containers.
- It has four components: ETCD, Scheduler, Controller and API Server
Master Node (Control Plane) components
- API Server
- Control Manager
Worker Node Components
Kubernetes Master server components
- It basically redirects all the API to a particular component, for example, if we wish to create a pod, then our request is received by the API server, and then it will forward it to the control manager.
- End-user only will talk to API server only.
- The API server will also authenticate and authorize the user
- Masters communicate with the rest of the cluster through the kube-apiserver, the main access point to the control plane.
- It validates and executes user’s REST commands
- kube-apiserver also makes sure that configurations in etcd match with configurations of containers deployed in the cluster
- ETCD is a distributed reliable key-value store used by Kubernetes to store all data used to manage the cluster.
- It is a database for k8, data is stored in the form of key-value pair.
- it has data of nodes, config, secret, accounts, role binding, replica set, replica controller, RBAC, etc.
- When you have multiple nodes and multiple masters in your cluster, etcd stores all that information on all the nodes in the cluster in a distributed manner.
- ETCD is responsible for implementing locks within the cluster to ensure there are no conflicts between the Masters
- The controllers are the brain behind orchestration.
- They are responsible for noticing and responding when nodes, containers or endpoints goes down.
- The controllers makes decisions to bring up new containers in such cases.
- The kube-controller-manager runs control loops that manage the state of the cluster by checking if the required deployments, replicas, and nodes are running in the cluster
- it will check for the number of workers in the k8 cluster is available for not.
- It will check for node state every 5 seconds, if any of the nodes will not respond for 40 seconds then node schedular will mark it as unreachable.
- After that, if that node still does not respond in the next 5 minutes, then k8 will schedule the pod present in that node to some other node
- Scheduler task is to schedule the tasks(like creating pod) on the proper node, it checks for the highest ram and storage available node and schedules the tasks accordingly, it basically manages the load between the nodes.
- It looks for newly created containers and assigns them to Nodes.
Kubernetes Worker node components
- Worker nodes have the kubelet agent that is responsible for interacting with the master to provide health information of the worker node
- To carry out actions requested by the master on the worker nodes.
- Kublet's task is to create the pod and monitor its status and provide the report to the API server.
- It will only manage containers which are created by k8 only
- Kube proxy will create and manage the network rules, it will help to establish communication between two pods which are in different nodes
- The kube-proxy is responsible for ensuring network traffic is routed properly to internal and external services as required and is based on the rules defined by network policies in kube-controller-manager and other custom controllers.
What is Kubectl
- kubectl is the command line utility using which we can interact with k8s cluster
- Uses APIs provided by API server to interact.
- Also known as the kube command line tool or kubectl or kube control.
- Used to deploy and manage applications on a Kubernetes