This blog targets the way modern applications are deployed and consumed. It introduces the architecture and components of Kubernetes, a container Orchestration tool on a basic level, and how it is making development more convenient.
What is Kubernetes (k8s)?
Kubernetes is an open-source orchestration tool developed by Google for managing microservices or containerized applications across a distributed cluster of nodes. Kubernetes became an open-source project in 2014. Today, now It is a part of the Cloud Native Computing Foundation (CNCF), And it is an essential container management solution used by millions of developers worldwide.
Kubernetes provides a 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 Architecture
Kubernetes (K8s) is an orchestration platform for containerized applications. It enables enterprises to automate the management and configuration of container workloads at scale.
A Kubernetes environment consists of a control plane (master), a distributed storage system for keeping the cluster state consistent (ETCD), and a number of worker nodes.
Master node: this node hosts the Kubernetes control plane and manages the cluster.
Worker node(s): runs your containerized applications.
Master Components:
Below are the main components found on the master node:
ETCD – A simple, distributed key-value storage that is used to store the Kubernetes cluster data (such as a number of pods, their state, namespace, etc). It is only accessible from the API server for security reasons. The API Server uses etcd data to monitor the cluster and enact changes to the cluster to resemble the desired state set.
API server – Kubernetes API server is the central management entity that receives all REST requests for modifications (to pods, services, replication sets/controllers and others). Also, this is the only component that communicates with the etcd cluster, making sure data is stored in etcd and is in agreement with the service details of the deployed pods.
Controller manager – The controller manager is a single process that encompasses all of the controllers within Kubernetes. While logically, the controllers are separate processes, they are run as a single process in a DaemonSet to reduce complexity. (for example, replication controller controls a number of replicas in a pod, endpoints controller populate endpoint objects like services and pods)
Scheduler – Helps schedule the pods on the various nodes based on resource utilization. It reads the service’s operational requirements and schedules it on the best fit node.
Node (worker) components
Kube-proxy: The kube-proxy component runs on each node and maintains network services on worker nodes. It also maintains network rules, allows network communication between services and pods, and is responsible for routing network traffic.
Kubelet: A kubelet runs on each node and communicates information about the state and health of containers to Kubernetes.
Container Runtime: The container runtime is the software that runs the containers.
Kubernetes Objects
Making use of Kubernetes requires understanding the different abstractions it uses to represent the state of the system, such as services, pods, volumes, namespaces, and deployments.
Pod – Pods are the smallest unit of deployment in Kubernetes. generally refers to one or more containers that should be controlled as a single application. A pod encapsulates application containers, storage resources, a unique network ID and other configurations on how to run the containers.
Deployment – A Kubernetes deployment is a resource object in Kubernetes that provides declarative updates to applications. A deployment allows you to describe an application's life cycle, such as which images to use for the app, the number of pods there should be, and the way in which they should be updated.
Service – A Kubernetes Service definition is also defined in YAML or JSON format. It creates a logical set of pods and creates policies for each set of pods that what type of ports and what type of IP address will be assigned. The Service identifies a set of target Pods by using Label Selector. Instead, a service represents a logical set of pods and acts as a gateway, allowing (client) pods to send requests to the service without needing to keep track of which physical pods actually make up the service.
Volume – Similar to a container volume in Docker, but a Kubernetes volume applies to a whole pod and is mounted on all containers in the pod. Kubernetes guarantees data is preserved across container restarts. The volume will be removed only when the pod gets destroyed. Also, a pod can have multiple volumes (possibly of different types) associated.
Namespace – A virtual cluster intended for environments with many users spread across multiple teams or projects, for isolation of concerns. Resources inside a namespace must be unique and cannot access resources in a different namespace. Also, a namespace can be allocated a resource quota to avoid consuming more than its share of the physical cluster’s overall resources.