Getting Started With Kubernetes
What is Kubernetes?
Kubernetes also known as K8S is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. Kubernetes provides you with a framework to run distributed systems resiliently. It takes care of scaling and failover for your application, provides deployment patterns, and more.
- scalability → as traffic increases/decreases, the number of container increases/decreases accordingly.
- Recovery → if any container dies, Kubernetes will replace it with a new container that also helps in high availability.
- Rollout & Rollback → if any update to configuration of containers leads to failure, Kubernetes will roll back to previous working state.
Terminologies:
- Cluster → A Kubernetes cluster can have at least one master node and one worker node. Although a cluster can have multiple master node and worker nodes. Example → a team working on some project where it can have one or more manager and one or more developers.
- Master Node → A master node is responsible for carrying out user requested services on worker nodes. Example → manager in a team gives task to other developer of that team.
- Worker Node → The worker node is a one who does the job/deployment. For example → manager (master node) asked first developer(worker node 1) to create a website and deploy it.
A cluster can have one or more master nodes and one or more worker nodes.
- Pod → Let’s say you want a three containers that have your application deployed and connected to outside world. So three containers means three different IPs then how Kubernetes will manage this? So what Kubernetes did, it created a wrapper called Pod and launched that three container inside it and assigned IPs to containers and a single IP to Pod. So the outside world will hit pod IP.
A worker Node can have one or more Pods and a Pod can have one or more containers.
- Service → pods that have same set of functions are abstracted into sets called services.
- Containers → A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
- Docker → A containerization tool used to launch containers.
A Pod contains:
- an application container/containers.
- a storage resource
- a unique network IP
Architecture of Kubernetes
Kubernetes has a cluster which contains master and worker nodes. Master node is responsible for taking the task from user and deploy it on worker nodes. Master node have basically 4 main components:
- API-Server → this component is responsible for all communication that is from user to master node, master to worker node and vice-versa. It provides some API so that user can connect to cluster via CLI(kubectl) or GUI(dashboard). It is a frontend for k8s control plane.
- Schedular → It watches for newly created Pods with no assigned node, and selects a node for them to run on. It gets the node configuration from ETCD component.
- Kube-Control-Manager → It runs health check and monitor the pods and nodes and acts accordingly. There are multiple controller process comes under it. Some of them are: Node controller → Responsible for noticing and responding when nodes go down. Job controller → Watches for Job objects that represent one-off tasks, then creates Pods to run those tasks to completion. Endpoints controller → Populates the Endpoints object (that is, joins Services & Pods). Service Account & Token controllers → Create default accounts and API access tokens for new namespaces. Replication controller → When a container dies it launches a new container and replace the died one.
- ETCD → it is an open source, distributed key-value database. ConfigMap component of k8s stores the configuration of nodes and pods in ETCD database. ETCD is a single source of truth for all components of the k8s cluster. Also secrets as such password, token keys are also stored in ETCD.
Worker Node also have 3 main components:
- Kubelet → An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod. It communicates to API-Server then master node can talk to worker node. If there is any issue with pods it try to restart the pod on same node or different node.
- Kube-proxy → It is a core networking component on each node responsible for maintaining network configuration and rules. It exposes services/pods to the outside world.
All Worker nodes run a daemon called kube-proxy, which watches the API-server so it can interact and communicate with master node and get all the information for addition & removal of services and endpoints.
- Container Runtime → It is a software that is responsible for running containers. Example → Docker, CRIO, Kubernetes CRI, containerd etc.
Let’s learn more about Kubernetes internal in the next blog of this series “Deep dive into Kubernetes”
Thank you for reading!!!