> For the complete documentation index, see [llms.txt](https://wtifs.gitbook.io/diva-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wtifs.gitbook.io/diva-notes/system-design/k8s.md).

# K 8 S

Kubernetes（简称K8s）是一个开源的容器编排平台，主要用于管理和部署容器化应用程序。Kubernetes提供了一组API和工具，可以轻松地自动化管理容器化应用程序的部署、伸缩、故障恢复和负载均衡等操作。它还提供了丰富的资源管理和监控功能，可以帮助用户有效地管理和调度容器。

**架构**

Kubernetes 的架构包括 Master 和 Node 两部分

Master 是 Kubernetes 的控制平面，主要负责管理和控制整个系统的状态和行为，包括资源管理、Pod 调度、弹性伸缩、安全控制、系统监控等，且都是自动完成的

Node 是集群中的工作节点，其上运行着真正的应用程序

**Service**

Service 是一种逻辑抽象，用于表示一组具有相同功能的 Pod 的访问方式和网络终结点。对外提供一个稳定的IP地址和DNS名称，使得客户端可以通过这个IP和DNS名称来访问Pod组，并通过负载均衡将请求分配到不同的Pod上。

**Pod**

Pod 是 k8s最小的部署单元，它是由一个或多个容器组成的、共享网络和存储资源的运行环境。

Pod 这个单词是豆荚的意思，里面包了多个豆子（容器）。

每个 Pod 中都运行着一个特殊的被称为 Pause 的容器，类似与边车模式里的代理，为其他业务容器提供共享的网络栈和存储，使业务容器之间的通信更加高效。因此在设计时可以充分利用这一特性将一组密切相关的进程放入同一 Pod 中。

**Container**

容器是一种轻量级的、可移植的、可隔离的软件包，用于打包应用程序和其依赖项以便在任何环境中运行。在k8s中，容器是Pod的基本组成部分，它包含应用程序、依赖项和运行时环境，并且在Pod中共享网络和存储资源。

**Node**

Node是k8s集群中的一个工作节点，它是集群中的一个物理机器或虚拟机器。上面运行一个或多个Pod，并且运行kubelet进程以接收和执行Pod的调度请求。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wtifs.gitbook.io/diva-notes/system-design/k8s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
