Kubernetes — Efficient Container Management: Understanding the Concepts and Architecture

Roman Glushach
7 min readAug 15, 2023
Kubernetes Container Orchestration Engine Architecture

A container orchestration engine is a system that automates the deployment, scaling, networking, service discovery, load balancing, health monitoring and configuration management of containers. Containers are lightweight and isolated environments that run applications and their dependencies. They offer many benefits such as faster development, portability, resource efficiency and consistency.

However, containers also introduce new challenges such as how to manage their lifecycle, how to coordinate their communication, how to distribute their load, how to handle their failures and how to secure their access. These challenges become more complex when dealing with hundreds or thousands of containers running on multiple nodes.

A container orchestration engine solves these challenges by providing a layer of abstraction and automation over the underlying infrastructure. It allows developers and operators to focus on the application logic and the desired state of the system, rather than the low-level details of the containers and the nodes.

Container Orchestration Engine Architecture

Container Orchestration Engine Architecture

A container orchestration engine is a software system that coordinates the operation of multiple containers on different hosts. It ensures that the containers are running in the right place, at the right time, and with the right resources. It also handles tasks such as load balancing, service discovery, networking, security, monitoring, and logging.

There are many container orchestration engines available in the market, such as Kubernetes, Docker Swarm, Mesos, Nomad, and Rancher. Each one has its own features, advantages, and disadvantages.

However, they all share some common characteristics:

  • use a declarative approach to define the desired state of the system. This means that you specify what you want to achieve, rather than how to achieve it. The orchestration engine then takes care of the details of how to make it happen
  • rely on a distributed architecture to achieve high availability, scalability, and fault tolerance. This means that they run on multiple nodes (or servers) that communicate with each other and form a cluster. The cluster can span across different regions, zones, or clouds
  • use a modular and extensible design to support different types of workloads and environments. This means that they can integrate with various technologies and platforms. For example, you can use different storage drivers, network plugins, or service meshes to enhance your container orchestration engine
  • have a deep tech knowledge of how containers work and interact with each other. This means that they can optimize the performance, efficiency, and security of the containerized applications

Kubernetes Architecture

Kubernetes Architecture

Kubernetes Cluster

The architecture of Kubernetes consists of two main components:

  • Control Plane: responsible for managing the cluster state and coordinating the communication between the worker nodes and the external clients
  • Worker Nodes: machines that run the containerized applications and provide the compute, storage, and network resources for them

Control Plane Nodes

  • kube-apiserver: This is the central hub of the cluster that exposes the Kubernetes API. It handles all the requests from end users, kubectl, and other cluster components. It also validates and updates the cluster state stored in etcd
  • etcd: This is a distributed key-value store that stores the cluster state and configuration. It is the source of truth for the cluster, and must be highly available and consistent
  • kube-schedule: This component decides which pods should run on which nodes, based on various factors such as resource requirements, node availability, affinity, anti-affinity. It watches for new pods that have no node assigned, and assigns them to a suitable node
  • kube-controller-manager: This component runs various controllers that manage different aspects of the cluster, such as node controller, replication controller, deployment controller, service controller. Controllers are loops that watch for changes in the cluster state, and reconcile the desired state with the actual state
  • cloud-controller-manager: This component interacts with the underlying cloud provider such as AWS, GCP, Azure to manage cloud-specific resources such as load balancers, storage volumes, network routes. It allows Kubernetes to integrate with different cloud platforms without affecting the core components

Worker Nodes

  • kubelet: This is the agent that runs on each node and communicates with the control plane. It registers the node with the cluster, reports its status and health, and manages the pods assigned to it. It also interacts with the container runtime to start and stop containers
  • kube-proxy: This is a network proxy that runs on each node and maintains network rules for pod-to-pod and pod-to-service communication. It implements various network modes such as iptables, ipvs, or userspace to ensure that pods can reach each other and external services
  • container runtime: This is the software that runs and manages containers on each node. Kubernetes supports various container runtimes such as Docker, containerd, CRI-O

Kubernetes Pod Networking

One of the key features of Kubernetes is its network model, which enables pods to communicate with each other across nodes without NAT. This means that each pod has a unique IP address that is routable within the cluster. To achieve this, Kubernetes relies on a network overlay that creates a virtual network on top of the physical network. There are many network plugins that implement this overlay, such as Calico, Flannel, Weave Net, Cilium.

The network overlay assigns a subnet to each node and allocates IP addresses to pods from that subnet. The network plugin also configures routes and iptables rules on each node to enable pod-to-pod communication across nodes. The network plugin also handles pod-to-service communication by implementing service discovery and load balancing mechanisms.

Cluster Addon Components

  • CNI plugin: This is a plugin that implements the Container Network Interface (CNI) specification and provides network connectivity for pods across nodes. There are many CNI plugins available for Kubernetes, such as Calico, Flannel, Weave Net
  • DNS: This is a service that provides DNS resolution for pod and service names within the cluster. It allows pods to communicate with each other using domain names instead of IP addresses
  • Dashboard: This is a web-based user interface that allows you to monitor and manage your cluster resources
  • Ingress controller: This is a controller that implements the Ingress resource and provides external access to services within the cluster. It allows you to define rules for routing HTTP(S) traffic to different services based on hostnames, paths
  • Metrics server: This is a service that collects and exposes metrics about the cluster nodes and pods, such as CPU, memory, disk, network. It is used by other components, such as the Horizontal Pod Autoscaler (HPA), to scale the pods based on resource utilization
  • Helm: The package manager that simplifies the deployment and management of applications on Kubernetes. It uses charts, which are collections of templates and values, to define and install applications

Kubernetes Core Principles

Kubernetes is designed to be extensible, modular and adaptable to different scenarios and requirements. It supports various types of workloads such as stateless, stateful, batch, daemon and cron jobs. It also integrates with various tools and platforms such as Docker, Helm, Istio, Prometheus, Grafana and more.

Kubernetes is based on a set of core principles such as:

  • Declarative configuration: Users define the desired state of the system using YAML or JSON files called manifests. Kubernetes reconciles the actual state with the desired state by creating, updating or deleting the resources accordingly
  • Self-healing: Kubernetes monitors the health and availability of the resources and takes corrective actions when needed. For example, it restarts failed containers, reschedules pods to healthy nodes, scales up or down replicas based on demand and more
  • Horizontal scaling: Kubernetes can scale the resources horizontally by adding or removing replicas of pods or nodes. This can be done manually or automatically based on metrics or events
  • Service discovery and load balancing: Kubernetes assigns unique IP addresses and DNS names to each pod and service. It also provides load balancing mechanisms to distribute the traffic among the pods of a service
  • Automated rollouts and rollbacks: Kubernetes can perform rolling updates or rollbacks of the resources without downtime or disruption. It also supports various deployment strategies such as blue-green, canary, A/B testing and more
  • Storage orchestration: Kubernetes can mount various types of storage volumes to the pods such as local disks, network-attached storage (NAS), cloud storage (S3, GCS), persistent volume claims (PVC) and more
  • Secret and configuration management: Kubernetes can store and manage sensitive data such as passwords, tokens, certificates and keys as secrets. It can also store and manage non-sensitive data such as environment variables, flags and parameters as config maps
  • Security: Kubernetes can enforce security policies and controls at different levels such as network policies, pod security policies, service accounts, role-based access control (RBAC), encryption at rest and in transit and more

Conclusion

Kubernetes architecture is designed to be modular, scalable, and extensible. It allows users to deploy applications in a consistent and reliable way across different environments. It also enables users to leverage various features and capabilities provided by Kubernetes and its ecosystem.

--

--

Roman Glushach

Senior Software Architect & Engineer Manager at Freelance