diff --git a/docs/en/_toc.yaml b/docs/en/_toc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3b118d51103025bf5fbdd461a64e4ac6c81049aa --- /dev/null +++ b/docs/en/_toc.yaml @@ -0,0 +1,6 @@ +label: K3s Deployment Guide +isManual: true +description: K3s is a lightweight Kubernetes distribution designed for edge computing and similar use cases +sections: + - label: K3s Deployment Guide + href: ./k3s_deployment_guide.md diff --git a/docs/en/figures/agent-install.png b/docs/en/figures/agent-install.png new file mode 100644 index 0000000000000000000000000000000000000000..dca1d64ec8aae821393bb715daf4c56b783a68e0 Binary files /dev/null and b/docs/en/figures/agent-install.png differ diff --git a/docs/en/figures/check-agent.png b/docs/en/figures/check-agent.png new file mode 100644 index 0000000000000000000000000000000000000000..aa467713353d70ad513e8ee13ac9d8b6520b7ee0 Binary files /dev/null and b/docs/en/figures/check-agent.png differ diff --git a/docs/en/figures/check-server.png b/docs/en/figures/check-server.png new file mode 100644 index 0000000000000000000000000000000000000000..06343de9a8b0eacb0f6194cf438b2b27af88cae4 Binary files /dev/null and b/docs/en/figures/check-server.png differ diff --git a/docs/en/figures/server-install.png b/docs/en/figures/server-install.png new file mode 100644 index 0000000000000000000000000000000000000000..7d30c8f4f73946c8b0555186c1736492039da731 Binary files /dev/null and b/docs/en/figures/server-install.png differ diff --git a/docs/en/figures/set-hostname.png b/docs/en/figures/set-hostname.png new file mode 100644 index 0000000000000000000000000000000000000000..32564d6159825b6d4131a6b138a493188ce88c6c Binary files /dev/null and b/docs/en/figures/set-hostname.png differ diff --git a/docs/en/figures/token.png b/docs/en/figures/token.png new file mode 100644 index 0000000000000000000000000000000000000000..79e5313bd1d5e707659cd08d4aafdf528b9df8f0 Binary files /dev/null and b/docs/en/figures/token.png differ diff --git a/docs/en/figures/yum-install.png b/docs/en/figures/yum-install.png new file mode 100644 index 0000000000000000000000000000000000000000..0e601a23a5a67e7927f12bc90d1a4137e1a3a567 Binary files /dev/null and b/docs/en/figures/yum-install.png differ diff --git a/docs/en/k3s_deployment_guide.md b/docs/en/k3s_deployment_guide.md new file mode 100644 index 0000000000000000000000000000000000000000..4d3e4050488715e01d034c314c9dff864710975f --- /dev/null +++ b/docs/en/k3s_deployment_guide.md @@ -0,0 +1,90 @@ +# K3s Deployment Guide + +## What Is K3s + +K3s is a lightweight Kubernetes distribution that is optimized for edge computing and IoT scenarios. The K3s provides the following enhanced features: + +- Packaged as a single binary file. +- Uses SQLite3-based lightweight storage backend as the default storage mechanism and supports etcd3, MySQL, and PostgreSQL. +- Encapsulated in a simple launcher that handles various complex TLS and options. +- Secure by default and has reasonable default values for lightweight environments. +- Batteries included, providing simple but powerful functions such as local storage providers, service load balancers, Helm controllers, and Traefik Ingress controllers. +- Encapsulates all operations of the Kubernetes control plane in a single binary file and process, capable of automating and managing complex cluster operations including certificate distribution. +- Minimizes external dependencies and requires only kernel and cgroup mounting. + +## Application Scenarios + +K3s is applicable to the following scenarios: + +- Edge computing +- IoT +- Continuous integration +- Development +- ARM +- Embedded Kubernetes + +The resources required for running K3s are small. Therefore, K3s is also suitable for development and test scenarios. In these scenarios, K3s facilitates function verification and problem reproduction by shortening cluster startup time and reducing resources consumed by the cluster. + +## Deploying K3s + +### Preparations + +- Ensure that the host names of the server node and agent node are different. + + You can run the `hostnamectl set-hostname "host name"` command to change the host name. + + ![1661829534335](./figures/set-hostname.png) + +- Install K3s on each node using Yum. + + The K3s official website provides binary executable files of different architectures and the **install.sh** script for offline installation. The openEuler community migrates the compilation process of the binary file to the community and releases the compiled RPM package. You can run the `yum` command to download and install K3s. + + ![1661830441538](./figures/yum-install.png) + +### Deploying the Server Node + +To install K3s on a single server, run the following command on the server node: + +```shell +INSTALL_K3S_SKIP_DOWNLOAD=true k3s-install.sh +``` + +![1661825352724](./figures/server-install.png) + +### Checking Server Deployment + +![1661825403705](./figures/check-server.png) + +### Deploying the Agent Node + +Query the token value of the server node. The token is stored in the **/var/lib/rancher/k3s/server/node-token** file on the server node. + +> [!NOTE]NOTE: +> +> Only the second half of the token is used. + +![1661825538264](./figures/token.png) + +Add agents. Run the following command on each agent node: + +```shell +INSTALL_K3S_SKIP_DOWNLOAD=true K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken k3s-install.sh +``` + +> [!NOTE]NOTE: +> +> Replace **myserver** with the IP address of the server or a valid DNS, and replace **mynodetoken** with the token of the server node. + +![1661829392357](./figures/agent-install.png) + +### Checking Agent Deployment + +After the installation is complete, run `kubectl get nodes` on the server node to check if the agent node is successfully registered. + +![1661826797319](./figures/check-agent.png) + +A basic K3S cluster is set up. + +### More + +For details about how to use K3s, visit the K3s [official website](https://rancher.com/docs/k3s/latest/en/). diff --git a/docs/zh/_toc.yaml b/docs/zh/_toc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bdc72240b6f340bbe3eabd3ebfc17772a3fb2868 --- /dev/null +++ b/docs/zh/_toc.yaml @@ -0,0 +1,6 @@ +label: K3s部署指南 +isManual: true +description: K3s 是一个轻量级的 Kubernetes 发行版,针对边缘计算等场景进行了优化 +sections: + - label: K3s部署指南 + href: ./k3s_deployment_guide.md diff --git a/docs/zh/figures/agent-install.png b/docs/zh/figures/agent-install.png new file mode 100644 index 0000000000000000000000000000000000000000..dca1d64ec8aae821393bb715daf4c56b783a68e0 Binary files /dev/null and b/docs/zh/figures/agent-install.png differ diff --git a/docs/zh/figures/check-agent.png b/docs/zh/figures/check-agent.png new file mode 100644 index 0000000000000000000000000000000000000000..aa467713353d70ad513e8ee13ac9d8b6520b7ee0 Binary files /dev/null and b/docs/zh/figures/check-agent.png differ diff --git a/docs/zh/figures/check-server.png b/docs/zh/figures/check-server.png new file mode 100644 index 0000000000000000000000000000000000000000..06343de9a8b0eacb0f6194cf438b2b27af88cae4 Binary files /dev/null and b/docs/zh/figures/check-server.png differ diff --git a/docs/zh/figures/server-install.png b/docs/zh/figures/server-install.png new file mode 100644 index 0000000000000000000000000000000000000000..7d30c8f4f73946c8b0555186c1736492039da731 Binary files /dev/null and b/docs/zh/figures/server-install.png differ diff --git a/docs/zh/figures/set-hostname.png b/docs/zh/figures/set-hostname.png new file mode 100644 index 0000000000000000000000000000000000000000..32564d6159825b6d4131a6b138a493188ce88c6c Binary files /dev/null and b/docs/zh/figures/set-hostname.png differ diff --git a/docs/zh/figures/token.png b/docs/zh/figures/token.png new file mode 100644 index 0000000000000000000000000000000000000000..79e5313bd1d5e707659cd08d4aafdf528b9df8f0 Binary files /dev/null and b/docs/zh/figures/token.png differ diff --git a/docs/zh/figures/yum-install.png b/docs/zh/figures/yum-install.png new file mode 100644 index 0000000000000000000000000000000000000000..0e601a23a5a67e7927f12bc90d1a4137e1a3a567 Binary files /dev/null and b/docs/zh/figures/yum-install.png differ diff --git a/docs/zh/k3s_deployment_guide.md b/docs/zh/k3s_deployment_guide.md new file mode 100644 index 0000000000000000000000000000000000000000..25d8de57030df62dd835442a1c7bc51584b9f828 --- /dev/null +++ b/docs/zh/k3s_deployment_guide.md @@ -0,0 +1,90 @@ +# K3s部署指南 + +## 什么是K3s + +K3s 是一个轻量级的 Kubernetes 发行版,它针对边缘计算、物联网等场景进行了高度优化。K3s 有以下增强功能: + +- 打包为单个二进制文件。 +- 使用基于 sqlite3 的轻量级存储后端作为默认存储机制。同时支持使用 etcd3、MySQL 和 PostgreSQL 作为存储机制。 +- 封装在简单的启动程序中,通过该启动程序处理很多复杂的 TLS 和选项。 +- 默认情况下是安全的,对轻量级环境有合理的默认值。 +- 添加了简单但功能强大的batteries-included功能,例如:本地存储提供程序,服务负载均衡器,Helm controller 和 Traefik Ingress controller。 +- 所有 Kubernetes control-plane 组件的操作都封装在单个二进制文件和进程中,使 K3s 具有自动化和管理包括证书分发在内的复杂集群操作的能力。 +- 最大程度减轻了外部依赖性,K3s 仅需要 kernel 和 cgroup 挂载。 + +## 适用场景 + +K3s 适用于以下场景: + +- 边缘计算(Edge Computing) +- 物联网(Internet of Things,IoT) +- 持续集成(Continuous Integration,CI) +- 开发(Development) +- 基于ARM的单板计算机(ARM-based single-board computers) +- 嵌入式K8s(Embedded K8s) + +由于运行 K3s 所需的资源相对较少,所以 K3s 也适用于开发和测试场景。在这些场景中,如果开发或测试人员需要对某些功能进行验证,或对某些问题进行重现,那么使用 K3s 不仅能够缩短启动集群的时间,还能够减少集群需要消耗的资源。 + +## 部署K3s + +### 准备工作 + +- 确保server节点及agent节点主机名不一致: + + 可以通过 `hostnamectl set-hostname “主机名”` 进行主机名的修改。 + + ![1661829534335](./figures/set-hostname.png) + +- 在各节点yum 安装 K3s: + + K3s官网采用下载对应架构二进制可执行文件的格式,通过install.sh脚本进行离线安装,openEuler社区将该二进制文件的编译过程移植到社区中,并编译出RPM包。此处可通过yum命令直接进行下载安装。 + + ![1661830441538](./figures/yum-install.png) + +### 部署server节点 + +如需在单个服务器上安装 K3s,可以在 server 节点上执行如下操作: + +```sh +INSTALL_K3S_SKIP_DOWNLOAD=true k3s-install.sh +``` + +![1661825352724](./figures/server-install.png) + +### 检查server部署情况 + +![1661825403705](./figures/check-server.png) + +### 部署agent节点 + +首先查询server节点的token值,该token可在server节点的/var/lib/rancher/k3s/server/node-token查到。 + +> [!NOTE]说明: +> +> 后续我们只用到该token的后半部分。 + +![1661825538264](./figures/token.png) + +选择添加其他 agent,请在每个 agent 节点上执行以下操作。 + +```sh +INSTALL_K3S_SKIP_DOWNLOAD=true K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken k3s-install.sh +``` + +> [!NOTE]说明: +> +> 将 myserver 替换为 server 的 IP 或有效的 DNS,并将 mynodetoken 替换 server 节点的 token。 + +![1661829392357](./figures/agent-install.png) + +### 检查agent节点是否部署成功 + +安装完毕后,回到 **server** 节点,执行 `kubectl get nodes`,可以看到agent节点已注册成功。 + +![1661826797319](./figures/check-agent.png) + +至此,一个基础的k3s集群搭建完成。 + +### 更多用法 + +K3s的更多用法可以参考K3s官网,