Introduction: Learning Objectives
In this section, we will be able to:
- Identify the components of a Kubernetes architecture,
- identify the components of a control plane,
- and identify the components of a worker plane.
Kubernetes Architecture
This architecture diagram highlights the main components in a Kubernetes system.
Kubernetes Control Plane
- A deployment of Kubernetes is called a Kubernetes cluster.
- A Kubernetes cluster is a cluster of nodes that runs containerized applications.
- Each cluster has one master node (the Kubernetes Control Plane) and one or more worker nodes.
- The control plane maintains the intended cluster state by making decisions about the cluster and detecting and responding to events in the cluster.
- As an analogy, it is similar to a thermostat. You specify the desired temperature, and the thermostat regulates heating and cooling systems continuously to achieve the specified state.
- An example of a decision made by the control plane is the scheduling of workloads, and an example of responding to an event is creating new resources when an application is deployed.
Kubernetes Worker Nodes
- Nodes are the worker machines in a Kubernetes cluster. In other words, user applications are run on nodes.
- Nodes are not created by Kubernetes itself, but rather by the cloud provider. This allows Kubernetes to run on a variety of infrastructures.
- The nodes are then managed by the control plane.
Kubernetes API Server
- In the Kubernetes control plane, the Kubernetes API server exposes the Kubernetes API.
- The API server serves as the front-end for the control plane.
- All communication in the cluster utilizes this API. For example, the Kubernetes API server accepts commands to view or change the state of the cluster.
- The main implementation of a Kubernetes API server is kube-apiserver which is designed to scale horizontally—by deploying more instances.
- You can run several instances of kube-apiserver and balance traffic between those instances.
Etcd
- Etcd is a highly available, distributed key value store that contains all the cluster data.
- When you tell Kubernetes to deploy your application, that deployment configuration is stored in etcd.
- Etcd defines the state in a Kubernetes cluster, and the system works to bring the actual state to match the desired state.
Scheduler
- The Kubernetes scheduler assigns newly created Pods to nodes.
- This basically means that the kube-scheduler determines where your workloads should run within the cluster.
- The scheduler selects the most optimal node according to Kubernetes scheduling principles, configuration options, and available resources.
Kubernetes Controller Manager
The Kubernetes controller manager runs all the controller processes that monitor the cluster state, and ensure the actual state of a cluster matches the desired state.
Cloud controller manager
Finally, the cloud controller manager runs controllers that interact with the underlying cloud providers. These controllers effectively link clusters into a cloud provider’s API. Since Kubernetes is open source and would ideally be adopted by a variety of cloud providers and organizations, Kubernetes strives to be as cloud agnostic as possible.
The cloud-controller-manager allows both Kubernetes and the cloud providers to evolve freely without introducing dependencies on the other.
Nodes
Nodes are the worker machines in a Kubernetes cluster. In other words, user applications are run on nodes. Nodes can be virtual or physical machines. Each node is managed by the control plane and contain the services necessary to run applications.
Nodes include pods, which are the smallest deployment entity in Kubernetes. Pods include one or more containers. Containers share all the resources of the node and can communicate among themselves.
Kubelet
The kubelet is the most important component of a worker node. This controller communicates with the kube-apiserver to receive new and modified pod specifications and ensure that the pods and their associated containers are running as desired.
The kubelet also reports to the control plane on the pods’ health and status. In order to start a pod, the kubelet uses the container runtime.
Container runtime
The container runtime is responsible for downloading images and running containers. Rather than providing a single container runtime, Kubernetes implements a Container Runtime Interface that permits pluggability of the container runtime.
While Docker is likely the best-known runtime, Podman and Cri-o are two other commonly used container runtimes.
Kubernetes proxy
Lastly, the Kubernetes proxy is a network proxy that runs on each node in a cluster. This proxy maintains network rules that allow communication to Pods running on nodes —in other words, communication to workloads running on your cluster.
This communication can come from within or outside of the cluster.
Summary
In this section, we learned that
- A control plane makes global decisions about the Kubernetes cluster.
- A control plane is made up of controllers, an API server, a scheduler, and an etcd.
- A worker plane is made up of the nodes, kubelet, container runtime, and kube-proxy.
- Worker nodes run important Kubernetes components as well as user workloads deployed on the cluster.
- The smallest deployable entity in Kubernetes is a pod which includes one or more containers.