Kubernetes控制平面,它如何与其主节点通信?

huangapple go评论57阅读模式
英文:

Kubernetes Control Plane, How it communicates with its masters?

问题

我有关于Kubernetes的一些问题。在阅读了一些资料之后,我对它有了一些了解。我将简要总结一下我的理解。它管理一组Pod,这些Pod是微服务/容器,每个Pod提供一项服务。而且,Pod的数据以与容器相同的方式存储,因此数据可以被其他Pod访问,因为它被容器化了。我假设,如果你想要多个数据库网关,你可以这样做。

如果它托管在单个主机上,你正在使用Kubernetes作为管理器来维护每个微服务的健康状态等等,这一切都是有道理的。

但我似乎无法理解的是,当你有多个主机时,这是如何工作的。一个Kubernetes如何与另一个Kubernetes通信?从技术上讲,我可以不断扩展我的虚拟机,但多个虚拟机如何协同工作并产生相同的效果?

感觉需要另一个更大的Kubernetes来管理它们。

@prasanna kumar提供了详细的解释。谢谢。

英文:

I have a few questions regarding Kubernetes. After reading around, I can somewhat understand what it is. I'll give a short summary on what I think it is. It manages a bunch of pods, that are micro-services/containers, which each pod provides a service. And the pod data is stored the same way as a container, so that the data is accessible by any other pods because it is containerized. I am assuming,if you want to have multiple database gateway, you can.

This all makes sense if it is hosted on a single host, and that you are using this kubernetes as a manager to maintain the health of each micro-service etc etc.

But what i cant seem to understand is how this works when you have more than 1 host. How does 1 kubernetes communicate with another kubernetes? I can just keep scaling up my VM technically, but how does multiple VM come together and have the same effect?

It feels like you need another bigger kubernetes to come in to manage them.

@prasanna kumar gave a detailed explanation. Thanks

答案1

得分: 1

现在,Kubernetes 主控制节点之间的通信是通过以下方式进行的:

  1. API 服务器
  2. etcd
  3. 控制器管理器

API 服务器:API 服务器是 Kubernetes 控制平面的核心组件,它公开 Kubernetes API。它接收来自用户、客户端和其他组件的请求,并与 etcd 存储通信以读取和更新集群的状态。每个主控制节点上的 API 服务器都连接到 etcd 集群,以访问和更新共享的配置数据。

etcd:etcd 是 Kubernetes 使用的分布式键值存储,用于存储和管理集群的配置数据和状态。它充当可靠的数据存储,所有主控制节点都可以访问。每个主控制节点都连接到 etcd 集群,以读取和写入有关集群状态的信息。

控制器管理器:控制器管理器运行各种控制器,监视集群的状态并进行必要的调整,以确保所需的状态得以维持。每个主控制节点上的控制器管理器与 API 服务器通信,以检索信息并根据所需的状态执行操作。

这些是在 Kubernetes 集群中的 Kubernetes 主控制节点之间进行通信和协调的核心组件。etcd 存储保存集群的配置和状态,API 服务器公开 Kubernetes API 并与 etcd 进行交互,控制器管理器根据所需的状态监视和管理集群。

这些组件共同确保 Kubernetes 主控制节点作为一个协调的单元共享信息,协调操作以维护集群的健康和功能性。

现在,在 Kubernetes 主控制节点内共享资源的方式如下:

假设您有一个 Kubernetes 集群,其中包含多个节点,可以是物理或虚拟机器。每个节点代表一个可以运行容器的主机。在多节点设置中,您可能有三个节点,标记为节点 A、节点 B 和节点 C。

在每个节点上,都有一个负责管理容器和执行 Pod 的 Kubernetes 运行时环境。

现在,假设您有一个 Kubernetes 集群,其中包含多个 Pod,每个 Pod 包含一个或多个容器。这些 Pod 代表您的微服务或应用程序。

Pod 是根据资源可用性和约束分布在节点上的。Kubernetes 调度程序组件决定将 Pod 放置在哪些节点上。

为了使运行在不同节点上的 Pod 之间能够通信,Kubernetes 在整个集群上建立了一个网络覆盖层。这个网络覆盖层为每个 Pod 提供了独特的 IP 地址,使它们能够无缝地相互通信。

因此,即使 Pod 1 运行在节点 A 上,而 Pod 2 运行在节点 B 上,它们仍可以使用各自的 IP 地址进行通信。

Kubernetes 的控制平面组件,包括 API 服务器、调度程序和控制器管理器,确保维护集群的所需状态。它们协调节点上的操作,以实现可伸缩性、高可用性和容错性。

如果您想要扩展 Kubernetes 集群本身,可以设置多个 Kubernetes 主控制节点。这些主控制节点一起工作并相互通信,以管理集群的状态并确保维护所需的状态。

通过拥有多个主控制节点,您确保如果一个主控制节点失败,其他节点可以接管并维护集群的运行。

这个可视化表示演示了 Kubernetes 如何管理多节点设置、分发 Pod、实现 Pod 之间的通信,并确保集群的健康和可伸缩性。

英文:

Now Kubernetes masters communication takes place via

  1. API Server
  2. etcd
  3. Controller manager

API Server: The API server is the central component of the Kubernetes control plane that exposes the Kubernetes API. It receives requests from users, clients, and other components and communicates with the etcd store to read and update the cluster's state. The API server on each master node connects to the etcd cluster to access and update the shared configuration data.

               +------------------------+
               |    Kubernetes Master 1  |
               |        API Server       |
               +------------------------+
                    |         ^
                    |         |
                    v         |
               +------------------------+
               |    Kubernetes Master 2  |
               |        API Server       |
               +------------------------+
                    |         ^
                    |         |
                    v         |
               +------------------------+
               |         etcd           |
               +------------------------+

etcd: etcd is a distributed key-value store used by Kubernetes to store and manage the cluster's configuration data and state. It serves as a reliable data store accessible by all the master nodes. Each master node connects to the etcd cluster to read and write information about the cluster's state.

               +------------------------+
               |    Kubernetes Master 1  |
               +------------------------+
                    |         ^
                    |         |
                    v         |
               +------------------------+
               |    Kubernetes Master 2  |
               +------------------------+
                    |         ^
                    |         |
                    v         |
               +------------------------+
               |         etcd           |
               +------------------------+

Controller Manager: The controller manager runs various controllers that monitor the state of the cluster and make necessary adjustments to ensure the desired state is maintained. The controller manager on each master node communicates with the API server to retrieve information and perform actions based on the desired state.

           +------------------------+
           |    Kubernetes Master 1  |
           |    Controller Manager   |
           +------------------------+
                |         ^
                |         |
                v         |
           +------------------------+
           |    Kubernetes Master 2  |
           |    Controller Manager   |
           +------------------------+
                |         ^
                |         |
                v         |
           +------------------------+
           |         etcd           |
           +------------------------+

These are the core components that facilitate communication and coordination between the Kubernetes masters in a cluster. The etcd store holds the cluster's configuration and state, the API server exposes the Kubernetes API and interacts with etcd, and the controller manager monitors and manages the cluster based on the desired state.

Together, these components ensure that the Kubernetes masters work together as a cohesive unit, sharing information, and coordinating actions to maintain the health and functionality of the cluster.

Now sharing of resources with in the Kubernetes master takes place as follows:

Imagine you have a Kubernetes cluster consisting of multiple nodes, which can be physical or virtual machines. Each node represents a host that can run containers. In a multi-node setup, you might have three nodes, labeled as Node A, Node B, and Node C.

       +------------------------+
       |         Node A         |
       +------------------------+
                /       \
               /         \
              /           \
+-------------------+   +-------------------+
|       Node B      |   |       Node C      |
+-------------------+   +-------------------+

On each node, there is a Kubernetes runtime environment responsible for managing containers and executing pods.

Now, let's say you have a Kubernetes cluster with multiple pods, each containing one or more containers. These pods represent your microservices or applications.

       +------------------------+
       |         Node A         |
       +------------------------+
                /       \
               /         \
              /           \
+-------------------+   +-------------------+
|     Pod 1         |   |    Pod 2          |
|                   |   |                   |
|   Container 1     |   |   Container 1     |
+-------------------+   +-------------------+

The pods are distributed across the nodes based on resource availability and constraints. The Kubernetes scheduler component decides which nodes to place the pods on.

To enable communication between pods running on different nodes, Kubernetes establishes a network overlay across the cluster. This network overlay provides each pod with its unique IP address, allowing them to communicate with each other seamlessly.

       +------------------------+
       |         Node A         |
       +------------------------+
                /       \
               /         \
              /           \
+-------------------+   +-------------------+
|     Pod 1         |   |    Pod 2          |
|   IP: 10.0.0.1    |   |   IP: 10.0.0.2    |
|                   |   |                   |
|   Container 1     |   |   Container 1     |
+-------------------+   +-------------------+

So, even though Pod 1 is running on Node A and Pod 2 is running on Node B, they can communicate with each other using their respective IP addresses.

The control plane components of Kubernetes, including the API server, scheduler, and controller manager, ensure that the desired state of the cluster is maintained. They coordinate the actions across the nodes to achieve scalability, high availability, and fault tolerance.

If you want to scale your Kubernetes cluster itself, you can set up multiple Kubernetes master nodes. These master nodes work together and communicate with each other to manage the cluster's state and ensure the desired state is maintained.

          +------------------------+
          |     Kubernetes Master 1 |
          +------------------------+
                      |
                      |
                      v
          +------------------------+
          |     Kubernetes Master 2 |
          +------------------------+

By having multiple master nodes, you ensure that if one master node fails, the other nodes can take over and maintain the cluster's operation.

This visual representation demonstrates how Kubernetes manages a multi-node setup, distributes pods, enables inter-pod communication, and ensures the cluster's health and scalability.

huangapple
  • 本文由 发表于 2023年5月25日 15:02:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76329647.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定