This article mainly introduces the architectural components of Kubernetes. Previously, we have learned about kubeadm and kubectl, which are two command-line tools that make up K8s. During the cluster setup, we also learned about the master and worker nodes; some concepts of K8s were introduced in the first and second articles. This article will discuss the key components and structures of K8s.
Architectural Composition
We can look at these two diagrams, which represent the architecture of a Kubernetes cluster.
A Kubernetes cluster consists of a set of machines or virtual machines known as nodes. The cluster is made up of master and worker nodes, with each machine having at least one worker node.
【Image source: Linux Foundation Official k8s Tutorial】
【Image source: Kubernetes Official Documentation】
Master
In the first two diagrams, we can see that the Master consists of a set of components known as the control plane components. We can open the /etc/kubernetes/manifests/
directory to find the default control plane components of K8s.
.
├── etcd.yaml
├── kube-apiserver.yaml
├── kube-controller-manager.yaml
└── kube-scheduler.yaml
For the cluster, etcd, apiserver, and scheduler are essential. Next, let’s understand the roles and related information of these components.
kube-apiserver
The kube-apiserver is one of the main processes of K8s. The apiserver component exposes the Kubernetes API, serving as the front end of the Kubernetes control plane. kubectl has powerful capabilities for controlling the cluster, and it is the apiserver that provides the interface service. After parsing the user input commands, kubectl sends HTTP requests to the apiserver and then returns the results to the user.
The exposed endpoint port is 6443. We join nodes to the cluster through kubeadm join ip:6443 ...
, which is processed by the apiserver.
etcd
etcd is a key-value database that ensures consistency and high availability, serving as the backend database for storing all cluster data of Kubernetes. All operation results of the kube-apiserver are stored in the etcd database, which primarily stores the state of K8s, network configurations, and other persistent data. etcd is implemented using a B+ tree.
kube-scheduler
The scheduler is responsible for monitoring newly created pods and allocating pods to nodes.
kube-controller-manager
The kube-controller-manager includes multiple controllers, all compiled into a single binary file but producing different processes upon startup. These controllers include:
-
Node Controller
Responsible for notifying and responding when a node fails.
-
Job Controller
Monitors Job objects representing one-time tasks and creates Pods to run these tasks until completion.
-
Endpoints Controller
Fills the Endpoints objects (i.e., joins Services with Pods).
-
Service Account & Token Controllers
Create default accounts and API access tokens for new namespaces.
Worker
Worker nodes are the nodes that perform the actual work. Each worker node runs two K8s components: kubelet and kube-proxy, as well as the container engine. The kube-apiserver comprises what are called control plane components, while the kubelet and kube-proxy are referred to as node components.
The kubelet interacts with the underlying container engine installed on the node, ensuring that the required containers are running in the pods. If we directly create containers using docker run
, the kubelet does not manage containers not created by Kubernetes.
The kube-proxy is responsible for managing the network connections of the containers. It runs as a network proxy on each node in the cluster and is part of the Service we learned about earlier.
文章评论