[Cloud Native] Components and Architecture of Kubernetes

quotation

In the previous article, we introduced what Kubernetes is. It can orchestrate containers, that is to say, it is the manager of containers. It can do load balancing for containers, mount storage systems, automate deployment and rollback, self-heal, and box, so how does Kubernetes do this? This has to mention the following important components of Kubernetes:

  • cluster components
  • Core idea
  • cluster installation

1. Cluster components

In MySQL, Redis... we have come into contact with the concept of clustering. To ensure the reliability of a service, clustering is an important solution. Kubernetes clusters also have different roles, each performing its own duties.

  • Cluster cluster: The process of organizing multiple nodes of the same software service together to provide services for the system is called the cluster of the software.

  • There are two roles of nodes in the k8s cluster:

    • master node / control plane control node, mainly used for container management, scheduling, resource allocation
    • work node The working node actually runs the container

When Kubernetes is deployed, you have a complete cluster, a set of worker machines, called nodes, that run containerized applications. Each cluster must have at least one worker node. The working node will host the Pod, and the Pod is a component of the application load. It is not a container, but a layer of packaging for the container. The control plane manages the working nodes and Pods in the cluster.

insert image description here

This picture is taken from the official website of Kubernetes. In this picture, we can see that in a Kubernetes cluster, in addition to the Node nodes we see, there is also a Control Plane (including kube-apiserver, etcd, kube-scheduler, kube-controller -manager, kube-controller-manager)

In the following, we will introduce the various components in the Kubernetes cluster and their functions:

1.1 Control Plane Components

Control plane components make global decisions for the cluster, such as scheduling of resources, detecting and responding to cluster events

Control plane components can run on any node of the cluster, but generally all control plane components will be started on the same machine, and user containers will not be run on this machine

  • The kube-apiserver
    API server is a component of the Kubernetes control plane. In fact, it is the main API entry provided by Kubernetes. The commands we write to operate Kubernetes will be received by the API server immediately, and are responsible for processing the work of accepting requests. kube-apiserver is the API The main implementation of server, that is, the main use is kube-apiserver, because it achieves horizontal scaling and can run multiple instances to achieve load balancing

  • Etcd
    is a consistent and highly available key-value store, which is used as the background database for all cluster data of Kubernetes, that is, cluster metadata, and the relevant information of the cluster is stored in this database

  • The kube-scheduler
    is responsible for scheduling components, responsible for monitoring newly created Pods that do not specify running nodes, and assigning nodes to Pods to run. The factors considered when assigning are:

    1. Pod resource requirements, hardware and software, and policy constraints
    2. Affinity and anti-affinity specifications (in fact, we specify which node it can run on when running the Pod is affinity, and specifying which node it cannot run on is anti-affinity)
    3. data location
    4. Interference between workloads and deadlines
  • Kube-controller-manager
    is similar to kube-apiserver: kube-controller-manager is the main implementation of Controller Manager, which is mainly responsible for running the controller process
    controller: There are the following four controllers in Kubernetes, we are running Pod Controller can be specified when

    • Node Controller: Responsible for notification and response when a node fails
    • Job Controller: Detects Job objects for one-off tasks, then creates Pods to run those tasks
    • Endpoint Slice Controller (EndpointSlice Controller): Expose Pod's external services through the connection between Service and Pod
    • Service Account Controller (ServiceAccount Controller): Create a default service account for new namespaces
      Logically, each controller is a separate process, but to reduce complexity, they are all compiled into the same executable file, and run it in the same process
  • cloud-controller-manager
    This is an optional component that embeds the control logic of a specific cloud platform, that is, connects the cluster to the cloud provider's API, so if you run the learning environment in your own environment or a local computer, The deployed cluster does not need this component. Similar to kube-controller-manager, it is also responsible for running the controller process. The
    following controllers all include dependencies on cloud platform drivers:

    • Node controller: used to check the cloud provider to determine if the node has been deleted after the node termination response
    • Routing Controller: Used to set up routing in the underlying cloud infrastructure
    • Service Controller: used to create, update and delete cloud provider load balancers

1.2 Node components

The node component will run on each node, responsible for maintaining the running Pod and providing the Kubernetes operating environment, responsible for maintaining and running the Pod, that is, the operation of the container is in charge of the Node component

  • Kubelet
    will run on each node to ensure that all containers are running in Pods.
    In other words, kubelet will accept configuration files provided by various mechanisms, and then ensure that the containers described by these configuration files can run normally. Containers created by Kubernetes
  • kube-proxy
    is used to implement the rules of internal and external network interaction. If you want to expose the Pod to the outside to provide services, that is, to be responsible for the network communication between the container and the outside world, you need to configure network rules to allow connections from the internal or external network of the cluster. container for network communication
  • Container Runtime (Container Runtime)
    Pod needs to wrap the Container, so it needs to run the container environment
    Kubernetes supports many container runtime environments, such as Containerd, CRI-0, Docker and any other implementation of Kubernetes CRI

1.3 Addons

  • Although DNS
    is a plug-in, it can be said to be a necessary component. Almost all Kubernetes clusters have DNS services
  • Web interface (dashboard)
    Dashboard is a common, web-based user interface for Kubernetes clusters, a program for managing applications running in the cluster
  • Container resource monitoring
    Container resource monitoring is to save some common time series metrics into a centralized data, and provide a visual page for browsing these data
  • Cluster-level logs
    Cluster-level logs are responsible for saving log data in a centralized log storage and providing interfaces for searching and browsing

2. Cluster construction

  • minikube
    is just a Kubernetes emulator, a cluster with only one node, its master and worker are together for testing
  • Bare metal installation
    requires at least two machines (one master node and one worker node), and you need to install Kubernetes components by yourself, which is more troublesome to configure Disadvantages: troublesome configuration, lack of ecological support, no load balancer, cloud storage
  • Directly use the cloud platform Kubernetes to build visually, and it only takes a few steps to create a cluster. Advantages: simple installation, complete ecology, load balancer, and cloud storage
  • k3s
  • Simple installation, automatic script completion Advantages: lightweight, low configuration requirements, simple installation, complete ecology

There is no demonstration here of how to build a cluster. Minikube is built automatically using Docker's visualization tools, and bare-metal installation is generally used for learning and use. Bloggers are built on bare metal, which requires a large amount of running memory, or use a cloud server

Summarize

This blog has a deeper understanding of the components in Kubernetes and the functions of each component in a Kubernetes cluster. Generally speaking, there are three types of components: control plane components, Node nodes, and plug-ins:

  • The control plane components generally run on a single machine without deploying pods
  • The Node node is for the normal operation and maintenance of the Pod
  • Plug-ins vary from person to person, but the DNS plug-in can be said to be a necessary plug-in, and another plug-in will be used in subsequent studies to check the response time

Guess you like

Origin blog.csdn.net/u011397981/article/details/130700418