What is Kubernetes?
- Kubernetes is an open-source, portable, cluster managed orchestration framework. Kubernetes allows to run containerized applications on multiple clusters for more reliable accessibility and organization.
- Kubernetes supports large scale deployments hence is best suited for enterprise-level containers and cluster management.
- Automates deployments and Upgrades, and rollbacks.
- Automates containers scalability and availability
- Maintain network setup for all containers within the cluster.
- Monitor service health and replace the containers when unhealthy
- Supports Service discovery and load balancing
- Provides enterprise-level container and cluster management services.
- Adjust the workload without redesigning the application.
- Cost effective solution to deploy microservices
- Flexibility in deploying and managing containers.
- Enhanced portability due to container isolation within the cluster.
- Kubernetes follows client-server architecture. One server is configured as Kubernetes Master node and other servers are configured as Kubernetes worker nodes.
- Kubernetes Master node is installed and configured with Kubernetes Engine that controls the cluster operations and deployments.
- Kubernetes Worker node is where containers will be scheduled and run.
Below diagram shows Kubernetes Architecture and its components for cluster operations.
- A container image is a ready-to-run software package, containing everything needed to run an application: the code and any runtime it requires, application and system libraries, and default values for any essential settings.
- Container is the smallest unit of software that can run applications and its dependencies so that application runs quickly and reliably on that container.
- A Pod is the basic execution unit of a Microservice application. Kubernetes manage running the containers in the Pod abstract layer. Usually a single Pod contains only on Container, but Pod can have multiple Container when those are having dependency each other to run.
- Containers within a Pod share an IP address and port space and can find each other via localhost.
A Kubernetes cluster consists of the components that represent the control plane and a set of machines called nodes.
Control Plane Components
etcd is the consistent and highly available key value database used by Kubernetes as backing store for all cluster data.
API Server exposes the Kubernetes API. API Server is the front-end component in the Kubernetes cluster. All cluster operational requests are receiving by API server to control the cluster operations.
Manages controller processes in the cluster, below are the controller processes responsible for various operations.
- Node controller: Responsible for noticing and responding when nodes go down.
- Replication controller: Responsible for maintaining the correct number of pods for every replication controller object in the system.
- 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
Scheduler is responsible to monitor newly created pod and assigns the node where the pod can run. Kube-scheduler consider various factors to select the node where the pod can run like,
- Individual and collective resource requirements
- Hardware/software/policy constraints
- Affinity and anti-affinity specifications
- Data locality
- Inter-workload interference, and deadlines.
Worker Node Components
An agent service that runs on each worker node in the cluster. Kubelet ensures that the containers are running in the Pod.
Kubelet manage Pods that are created by Kubernetes. Kubelet takes the Pod Specification defined in the manifest and ensure that the containers are deployed accordingly and the healthy in the Pods.
Kubelet-proxy is the network proxy that runs on each worker node to expose the services to the internet or public network.
Container runtime is the software that run containers in the Pods. Kubernetes supports below container runtimes:
Among these, Docker is the most widely used container runtime to deploy containers managed within the Pods Kubernetes.