diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/_category_.json new file mode 100644 index 00000000..9e0cf694 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Application Layer", + "position": 7, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection1.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection1.png new file mode 100644 index 00000000..06f09077 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection1.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection2.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection2.png new file mode 100644 index 00000000..2316931a Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/fault_injection2.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/kiali.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/kiali.png new file mode 100644 index 00000000..608caf2f Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/kiali.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing1.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing1.png new file mode 100644 index 00000000..2c9b6e7e Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing1.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing2.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing2.png new file mode 100644 index 00000000..0ba918ce Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_routing2.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout1.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout1.png new file mode 100644 index 00000000..4c260b6e Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout1.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout2.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout2.png new file mode 100644 index 00000000..555a502e Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/images/request_timeout2.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/install_waypoint.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/install_waypoint.md new file mode 100644 index 00000000..7378ee7f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/install_waypoint.md @@ -0,0 +1,170 @@ +--- +sidebar_position: 3 +title: 安装 Waypoint +--- + +如果您想使用 Kmesh 的 L7 功能,安装 waypoint 是先决条件。 + +## 准备工作 + +1. **安装 Kmesh**: + + 请参阅[快速入门](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md) + +2. **部署示例应用程序**: + + 使用 Kmesh 管理 `default` 命名空间 + + ```bash + [root@ ~]# kubectl label namespace default istio.io/dataplane-mode=Kmesh + [root@ ~]# kubectl get namespace -L istio.io/dataplane-mode + NAME STATUS AGE DATAPLANE-MODE + default Active 13d Kmesh + istio-system Active 13d + kmesh-system Active 27h + kube-node-lease Active 13d + kube-public Active 13d + kube-system Active 13d + local-path-storage Active 13d + ``` + +3. **部署 `bookinfo`**: + + ```bash + [root@ ~]# kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/bookinfo/platform/kube/bookinfo.yaml + ``` + +4. **部署 `sleep` 作为 curl 客户端**: + + ```bash + [root@ ~]# kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/sleep/sleep.yaml + [root@ ~]# kubectl get pods + NAME READY STATUS RESTARTS AGE + details-v1-5f4d584748-bz42z 1/1 Running 0 72s + productpage-v1-564d4686f-2rjqc 1/1 Running 0 72s + ratings-v1-686ccfb5d8-dnzkf 1/1 Running 0 72s + reviews-v1-86896b7648-fqm4z 1/1 Running 0 72s + reviews-v2-b7dcd98fb-nn42q 1/1 Running 0 72s + reviews-v3-5c5cc7b6d-q4r5h 1/1 Running 0 72s + sleep-9454cc476-86vgb 1/1 Running 0 62s + ``` + +5. **测试 `bookinfo` 按预期工作**: + + ```bash + [root@ ~]# kubectl exec deploy/sleep -- curl -s http://productpage:9080/ | grep -o ".*" + Simple Bookstore App + ``` + +## 安装 Waypoint + +Waypoint 可以在三种粒度级别使用:命名空间、服务和 Pod。您还可以在一个命名空间内为不同粒度安装多个 waypoint。下面我们将学习如何为不同粒度部署不同的 waypoint。我们可以使用 `kmeshctl waypoint` 子命令来生成或应用 waypoint。 + +要启用命名空间、服务或 Pod 使用 waypoint,请添加 `istio.io/use-waypoint` 标签,并将值设置为 waypoint 名称。我们还可以通过 `--image` 指定自定义的 waypoint 镜像,默认情况下为 `ghcr.io/kmesh-net/waypoint:{VERSION}`。 + +### 为特定服务配置 Waypoint + +为服务 `reviews` 部署一个 waypoint `reviews-svc-waypoint`,这样从 Kmesh 管理的客户端到 `reviews` 的任何流量都将由 waypoint 代理调解。 + +```bash +[root@ ~]# kmeshctl waypoint apply --for service -n default --name=reviews-svc-waypoint + +waypoint default/reviews-svc-waypoint applied +``` + +为 `reviews` 服务添加标签以使用 `reviews-svc-waypoint` waypoint: + +```bash +[root@ ~]# kubectl label service reviews istio.io/use-waypoint=reviews-svc-waypoint + +service/reviews labeled +``` + +waypoint 启动并运行后,Kmesh L7 功能即启用! + +```bash +[root@ ~]# kubectl get pods +NAME READY STATUS RESTARTS AGE +details-v1-cdd874bc9-xcdnj 1/1 Running 0 30m +productpage-v1-5bb9985d4d-z8cws 1/1 Running 0 30m +ratings-v1-6484d64bbc-pkv6h 1/1 Running 0 30m +reviews-svc-waypoint-8cb4bdbf-9d5mj 1/1 Running 0 30m +reviews-v1-598f9b58fc-2rw7r 1/1 Running 0 30m +reviews-v2-5979c6fc9c-72bst 1/1 Running 0 30m +reviews-v3-7bbb5b9cf7-952d8 1/1 Running 0 30m +sleep-5577c64d7c-n7rxp 1/1 Running 0 30m +``` + +### 为特定命名空间配置 Waypoint + +为 `default` 命名空间部署一个默认名称为 `waypoint` 的 waypoint。通过指定 `--enroll-namespace`,命名空间将被标记为 `istio.io/use-waypoint=waypoint`。 + +```bash +[root@ ~]# kmeshctl waypoint apply -n default --enroll-namespace +waypoint default/waypoint applied +namespace default labels with "istio.io/use-waypoint: waypoint" +``` + +### 为特定 Pod 配置 Waypoint + +为 Pod `reviews-v2-5979c6fc9c-72bst` 部署一个名为 `reviews-v2-pod-waypoint` 的 waypoint。 + +```bash +[root@ ~]# kmeshctl waypoint apply -n default --name reviews-v2-pod-waypoint --for workload +waypoint default/reviews-v2-pod-waypoint applied +# 为 `reviews-v2` Pod 添加标签以使用 `reviews-v2-pod-waypoint` waypoint。 +[root@ ~]# kubectl label pod reviews-v2-5979c6fc9c-72bst istio.io/use-waypoint=reviews-v2-pod-waypoint +pod/reviews-v2-5b667bcbf8-spnnh labeled +``` + +现在,Kmesh 中的 Pod 发往 `reviews-v2` Pod IP 的任何请求都将通过 `reviews-v2-pod-waypoint` waypoint 进行 L7 处理和策略执行。 + +## 清理 + +如果您**不**打算探索任何后续任务,请继续执行清理步骤。 + +1. **移除 Waypoint**: + +**移除服务的 Waypoint** + + ```bash + [root@ ~]# kmeshctl waypoint delete reviews-svc-waypoint + [root@ ~]# kubectl label service reviews istio.io/use-waypoint- + ``` + +**移除命名空间的 Waypoint** + + ```bash + [root@ ~]# kmeshctl waypoint delete waypoint + [root@ ~]# kubectl label namespace default istio.io/use-waypoint- + ``` + +**移除 Pod 的 Waypoint** + + ```bash + [root@ ~]# kmeshctl waypoint delete reviews-v2-pod-waypoint + [root@ ~]# kubectl label pod -l version=v2,app=reviews istio.io/use-waypoint- + ``` + +2. **移除示例应用程序**: + + ```bash + [root@ ~]# kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/bookinfo/platform/kube/bookinfo.yaml + [root@ ~]# kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/sleep/sleep.yaml + ``` + +3. **从 Kmesh 中移除 `default` 命名空间**: + + ```bash + [root@ ~]# kubectl label namespace default istio.io/dataplane-mode- + ``` + +## 演示 + +
+ +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/kiali.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/kiali.md new file mode 100644 index 00000000..5f31754d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/kiali.md @@ -0,0 +1,61 @@ +--- +sidebar_position: 8 +title: 使用 Kiali 可视化 Kmesh 下的流量图 +--- + +## 准备工作 + +1. **使默认命名空间由 Kmesh 管理。** + +2. **部署 bookinfo 作为示例应用程序,并部署 sleep 作为 curl 客户端。** + +3. **[可选] 为服务 `reviews` 安装服务粒度的 waypoint。** + _以上步骤可参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)。在安装 Istio 时,我们建议安装 Istio 的 ambient 模式,而不是仅安装 Istiod,因为 Kiali 目前依赖 Istio 组件才能正常工作。_ + +4. **部署 Prometheus 来记录 Kmesh 指标,并将其转换为 Istio 标准指标。** + _此 Prometheus 插件利用 Prometheus 记录规则和重新标记配置,将 Kmesh 的 L4 指标转换为 Istio 标准指标,以便 Kiali 能够可视化这些指标。_ + + ```bash + kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus_recording_istio.yaml + ``` + +5. **部署 Kiali,从 Prometheus 读取指标。** + + ```bash + kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/kiali.yaml + ``` + +## 在网格中的应用程序之间生成一些持续的流量 + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +## 使用 Kiali 可视化服务的流量图 + +1. **使用 port-forward 命令将流量转发到 Kiali。** + + ```bash + kubectl port-forward --address 0.0.0.0 svc/kiali 20001:20001 -n kmesh-system + Forwarding from 0.0.0.0:20001 -> 20001 + ``` + +2. **从浏览器查看 Kiali 中的流量图。** + 访问 `Traffic Graph` 面板。在左侧顶部选择 `default` 命名空间。 + ![image](images/kiali.png) + _在此流量拓扑图中,蓝色线条代表 TCP 流量,由 Kmesh 代理,而绿色线条代表 HTTP 流量,由 Waypoint 代理。有关 Kiali 流量拓扑图的更多信息,请参阅 [Kiali 文档](https://kiali.io/docs/features/topology/)。_ + +## 清理 + +1. **移除 Prometheus 和 Grafana:** + + ```bash + kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus_recording_istio.yaml + kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/kiali.yaml + ``` + +2. **如果您不打算探索任何后续任务,请参考 [安装 Waypoint/清理](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#清理) 说明来移除 waypoint 并关闭应用程序。** + +--- + +This translation ensures that the document is accessible to Chinese-speaking users while maintaining the technical integrity of the original content. diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/locality-loadbalance.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/locality-loadbalance.md new file mode 100644 index 00000000..9e96911f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/locality-loadbalance.md @@ -0,0 +1,376 @@ +--- +sidebar_position: 9 +title: 地域负载均衡 +--- + +本文档介绍如何在 Kmesh 中使用 Istio 的地域负载均衡功能。 + +> 当前的 Kmesh 地域负载均衡处于 L4 级别,仅支持[地域故障转移](https://istio.io/latest/docs/tasks/traffic-management/locality-load-balancing/failover/)。 + +## 什么是地域负载均衡? + +地域定义了网格中工作负载实例的地理位置。服务网格中的地域负载均衡通过根据服务实例的位置智能路由流量,有助于提高服务的可用性和性能。 + +我们强烈建议您首先阅读 https://istio.io/latest/docs/tasks/traffic-management/locality-load-balancing/ 以了解地域负载均衡的概念。 + +## Kmesh 支持的模式和配置方法 + +目前,Istio 的 ambient 模式仅支持通过配置特定字段来指定固定的地域负载均衡策略。这包括两种模式:PreferClose 和 Local。 + +### 1. PreferClose + +一种故障转移模式,使用 NETWORK、REGION、ZONE 和 SUBZONE 作为 routingPreference。 + +- 使用 `spec.trafficDistribution`(k8s >= beta [1.31.0](https://kubernetes.io/docs/concepts/services-networking/service/), istio >= [1.23.1](https://istio.io/latest/news/releases/1.23.x/announcing-1.23/)) + + ```yaml + spec: + trafficDistribution: # spec.trafficDistribution + preferClose: true + ``` + +- 使用 annotation + + ```yaml + metadata: + annotations: + networking.istio.io/traffic-distribution: PreferClose + ``` + +### 2. Local + +一种严格模式,仅匹配当前 NODE。 + +- spec.internalTrafficPolicy: Local (k8s >= beta 1.24 或 >= 1.26) + + ```yaml + spec: + internalTrafficPolicy: Local + ``` + +## 实验测试 + +### 准备环境 + +- 参考[在 kind 中开发](/i18n/zh/docusaurus-plugin-content-docs/current/setup/develop-with-kind.md) +- 我们在集群中准备了三个节点 +- istio >= 1.23.1 +- k8s >= 1.31.0 +- 确保 sidecar 注入已禁用:`kubectl label namespace default istio-injection-` +- 所需镜像: + - docker.io/istio/examples-helloworld-v1 + - curlimages/curl + +```yaml +kind create cluster --image=kindest/node:v1.31.0 --config=- < + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-routing.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-routing.md new file mode 100644 index 00000000..3da5279c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-routing.md @@ -0,0 +1,167 @@ +--- +sidebar_position: 4 +title: 尝试请求路由 +--- + +## 准备工作 + +1. 使默认命名空间由 Kmesh 管理 +2. 部署 Bookinfo 作为示例应用程序,并部署 sleep 作为 curl 客户端 +3. 为 reviews 服务安装服务粒度的 waypoint + + _以上步骤可以参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)_ + +## 应用基于版本的路由 + +1. 运行以下命令创建路由规则: + +```bash +kubectl apply -f -<reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + ... + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r +``` + +## 应用基于用户身份的路由 + +接下来,您将更改路由配置,以便来自特定用户的所有流量路由到特定的服务版本。在本例中,来自名为 Jason 的用户的所有流量将路由到服务 `reviews:v2`。 + +此示例得以实现,是因为 `productpage` 服务向发送到 reviews 服务的出站 HTTP 请求添加了自定义的 `end-user` 标头。 + +1. 运行以下命令启用基于用户的路由: + +```bash +kubectl apply -f -< + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-timeout.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-timeout.md new file mode 100644 index 00000000..e4183604 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-request-timeout.md @@ -0,0 +1,130 @@ +--- +sidebar_position: 7 +title: 尝试请求超时 +--- + +# 尝试请求超时 + +## 准备工作 + +1. **使默认命名空间由 Kmesh 管理** + +2. **部署 Bookinfo 作为示例应用程序** + +3. **为 reviews 服务安装服务粒度的 waypoint** + + _以上步骤可以参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)_ + +4. **为 ratings 服务安装 waypoint** + + ```bash + istioctl x waypoint apply -n default --name ratings-svc-waypoint + kubectl label service ratings istio.io/use-waypoint=ratings-svc-waypoint + kubectl annotate gateway ratings-svc-waypoint sidecar.istio.io/proxyImage=ghcr.io/kmesh-net/waypoint:latest + ``` + +## 请求超时 + +HTTP 请求的超时时间可以通过路由规则中的 `timeout` 字段指定。默认情况下,请求超时是禁用的,但在这个任务中,您将 `reviews` 服务的超时时间设置为半秒。为了观察其效果,您还需要在调用 `ratings` 服务时人为引入 2 秒的延迟。 + +1. **将请求路由到 reviews 服务的 v2 版本,即调用 ratings 服务的版本:** + + ```bash + kubectl apply -f - < + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-service-entry.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-service-entry.md new file mode 100644 index 00000000..52360607 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/application-layer/try-service-entry.md @@ -0,0 +1,224 @@ +--- +sidebar_position: 5 +title: 尝试 Service Entry +--- + +Service Entry 允许您将外部服务添加到 Istio 的内部服务注册表中,使网格中的服务能够访问和路由到这些手动指定的服务。本指南将向您展示如何使用 Service Entry 配置对外部服务的访问。 + +## 准备工作 + +在开始之前,请确保完成以下步骤: + +1. **使默认命名空间由 Kmesh 管理** +2. **部署 Httpbin 作为示例应用程序,并部署 Sleep 作为 curl 客户端** +3. **为默认命名空间安装 waypoint** + + _以上步骤的详细说明可以参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)_ + +## 验证环境设置 + +确认 httpbin 和 sleep 应用程序已正常运行: + +```bash +kubectl get pods +``` + +您应该看到两个服务都处于 Running 状态: + +```bash +NAME READY STATUS RESTARTS AGE +httpbin-6f4464f6c5-h9x2p 1/1 Running 0 30s +sleep-9454cc476-86vgb 1/1 Running 0 5m +``` + +## 配置 Service Entry + +我们将创建一个 Service Entry 来定义一个虚拟的外部服务,该服务实际上会将流量路由到集群内的 httpbin 服务: + +```bash +kubectl apply -f - <reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + ... + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 +``` + +## 理解发生了什么 + +由于 `default` 命名空间已由 Kmesh 管理,并且我们为服务 `bookinfo-reviews` 部署了 waypoint 代理,因此发送到服务 `reviews` 的所有流量都将由 Kmesh 转发到 waypoint。Waypoint 将根据我们设置的路由规则将 90% 的请求发送到 `reviews v1`,10% 发送到 `reviews v2`。 + +## 清理 + +1. **删除应用程序路由规则:** + +```bash +kubectl delete virtualservice reviews +kubectl delete destinationrules reviews +``` + +2. **如果您不打算继续探索后续任务** + 请参考 [安装 Waypoint/清理](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#清理) 说明删除 waypoint 并关闭应用程序。 + +## 演示 + +
+ +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/_category_.json new file mode 100644 index 00000000..7d9d2cf5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Architecture", + "position": 3, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/architecture.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/architecture.md new file mode 100644 index 00000000..ff845e12 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/architecture.md @@ -0,0 +1,40 @@ +--- +title: Kmesh 架构 +description: "" +sidebar_position: 1 +--- + +![image](images/kmesh-arch.png) + +## 架构概述 + +Kmesh 的软件架构由以下核心组件构成: + +| 组件 | 描述 | +| ------------------ | ------------------------------------------------------------------ | +| Kmesh-daemon | 负责 eBPF 编排生命周期管理、xDS 协议集成、可观察性等功能的守护进程 | +| eBPF Orchestration | 使用 eBPF 实现的流量编排,包括动态路由、授权、负载均衡 | +| Waypoint | 基于 istio 的 waypoint 适配 Kmesh 协议,负责 L7 流量管理 | + +## 组件详情 + +### Kmesh-daemon + +- eBPF 生命周期管理 +- xDS 协议集成 +- 可观察性和监控 +- 配置管理 + +### eBPF Orchestration + +- 动态路由实现 +- 授权 +- 负载均衡优化 +- 流量加速 + +### Waypoint + +- L7 流量管理 +- Kmesh 协议适配 +- 服务网格集成 +- 流量策略执行 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.png new file mode 100644 index 00000000..8acbdaea Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.svg b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.svg new file mode 100644 index 00000000..0dcd6925 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/images/kmesh-arch.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/roadmap.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/roadmap.md new file mode 100644 index 00000000..9d1e6cf2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/architecture/roadmap.md @@ -0,0 +1,31 @@ +--- +title: 路线图 +description: "" +sidebar_position: 2 +--- + +| Feature Domain | Feature | 2023.H1 | 2023.H2 | 2024.H1 | 2024.H2 | +| --------------------------------- | -------------------------------------- | :-----: | :-----: | :-----: | :-----: | +| **Traffic Management** | Sidecarless mesh | ✓ | | | | +| | Sockmap | | ✓ | | | +| | Programmable governance based on eBPF | ✓ | | | | +| | HTTP1.1 protocol | ✓ | | | | +| | HTTP2 protocol | | | | ✓ | +| | gRPC protocol | | | | ✓ | +| | QUIC protocol | | | | ✓ | +| | TCP protocol | | ✓ | | | +| | Retry | | | ✓ | | +| | Routing | ✓ | | | | +| | Load balancing | ✓ | | | | +| | Fault injection | | | | ✓ | +| | Gray release | ✓ | | | | +| | Circuit Breaker | | | ✓ | | +| | Rate Limits | | | ✓ | | +| **Service Security** | SSL-based two-way authentication | | | | ✓ | +| | L7 authorization | | | | ✓ | +| | Cgroup-level isolation | ✓ | | | | +| **Traffic Monitoring** | Governance indicator monitoring | | ✓ | | | +| | End-to-end observability | | | | ✓ | +| **Programmable** | Plug-in expansion capability | | | | ✓ | +| **Ecosystem Collaboration** | Data plane collaboration (Envoy, etc.) | | ✓ | | | +| **Operating Environment Support** | Container | ✓ | | | | diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/_category_.json new file mode 100644 index 00000000..7bec99d9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Community", + "position": 6, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/contribute.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/contribute.md new file mode 100644 index 00000000..b7bf4184 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/contribute.md @@ -0,0 +1,22 @@ +--- +title: 参与贡献 +sidebar_position: 1 +--- + +## 行为准则 + +Kmesh 遵循 [CNCF 行为准则](https://github.com/cncf/foundation/blob/main/code-of-conduct.md)。 + +如果发现滥用、骚扰或其他不可接受的行为,请通过 [kmesh.net.dev@gmail.com](mailto:kmesh.net.dev@gmail.com) 联系项目团队报告。 + +## 社区期望 + +Kmesh 是一个由社区驱动的项目,致力于促进健康、友好和高效的环境。社区的目标是构建一个高性能的服务治理框架,这需要有共同愿景的社区的支持。 + +- 请参阅[社区成员](membership.md)了解各种社区角色的列表。通过逐步的贡献,一个人可以在社区角色中晋升。 + +## 准备工作 + +- 在 GitHub 上 fork 仓库 +- 下载仓库 +- 阅读 [CONTRIBUTING](https://github.com/kmesh-net/kmesh/blob/main/CONTRIBUTING.md) 了解更多详情 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/feature-lifecycle.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/feature-lifecycle.md new file mode 100644 index 00000000..a82fb7ac --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/feature-lifecycle.md @@ -0,0 +1,79 @@ +--- +title: 特性生命周期 +sidebar_position: 2 +--- + +本文档旨在明确在不同开发阶段(版本)中,特性和相应 API 的定义和区别。 + +每个版本都有不同的稳定性、支持时间以及升级到下一级别的不同毕业标准: + +- [Alpha](#alpha) +- [Beta](#beta) +- [GA](#ga) + +## Alpha + +该特性在后续版本中可能会以不兼容的方式进行更改/升级。 + +源代码将在发布分支/标签以及二进制文件中提供。 + +对该特性的支持可能随时停止,恕不另行通知。 + +该特性可能存在错误。 + +如果启用该特性,可能会在其他 API/特性中引发错误。 + +该特性可能未完全实现。 + +API 版本名称将类似于 v1alpha1、v1alpha2 等。每次升级时,后缀数字将增加 1。 + +### 毕业标准 + +- 每个特性都将从 alpha 级别开始。 +- 不应破坏其他 API/特性的功能。 + +## Beta + +该特性在后续版本中可能不会以不兼容的方式进行更改/升级,但如果以不兼容的方式进行更改,则将提供升级策略。 + +源代码将在发布分支/标签以及二进制文件中提供。 + +对该特性的支持不会在未提前 2 个次要版本通知的情况下停止,并且将至少在接下来的 2 个次要版本中存在。 + +该特性将有少量错误。 + +如果启用该特性,不会引发其他 API/特性中的错误。 + +该特性将完全实现。 + +API 版本名称将类似于 v1beta1、v1beta2 等。每次升级时,后缀数字将增加 1。 + +### 毕业标准 + +- 应在 e2e 测试中至少有 50% 的覆盖率。 +- 项目同意在至少接下来的 2 个次要版本中支持此特性,并在停止支持前提供至少 2 个次要版本的通知。 +- 特性所有者应承诺确保在后续版本中的向后/向前兼容性。 + +## GA + +该特性在接下来的几个版本中不会以不兼容的方式进行更改/升级。 + +源代码将在发布分支/标签以及二进制文件中提供。 + +对该特性的支持不会在未提前 4 个次要版本通知的情况下停止,并且将至少在接下来的 4 个次要版本中存在。 + +该特性将不会存在重大错误,因为它将经过完全测试并进行 e2e 测试。 + +如果启用该特性,不会引发其他 API/特性中的错误。 + +该特性将完全实现。 + +API 版本名称将类似于 v1、v2 等。 + +### 毕业标准 + +- 应具有完整的 e2e 测试。 +- 代码经过彻底测试,并被报告为非常稳定。 +- 项目将至少在接下来的 4 个次要版本中支持此特性,并在停止支持前提供至少 4 个次要版本的通知。 +- 特性所有者应承诺确保在后续版本中的向后/向前兼容性。 +- 来自 Kmesh 维护者以及使用/交互该特性/API 的特性/API 所有者的共识。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/governance.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/governance.md new file mode 100644 index 00000000..8d27eeda --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/governance.md @@ -0,0 +1,64 @@ +--- +title: 治理 +sidebar_position: 3 +--- + +# Kmesh-项目治理 + +Kmesh 是一个基于 eBPF 和可编程内核的高性能、低开销服务网格数据平面。本治理文档阐述了项目的运行方式。 + +- [价值观](#价值观) +- [成员资格](#成员资格) +- [会议](#会议) +- [行为准则](#行为准则) +- [安全响应小组](#安全响应小组) +- [投票](#投票) +- [修改本章程](#修改本章程) + +## 价值观 + +Kmesh 及其领导层秉持以下价值观: + +- **开放性**:沟通和决策在公开的环境中进行,并且未来可以查阅。所有讨论和工作尽可能在公共论坛和开放仓库中进行。 + +- **公平性**:所有利益相关者都有机会提供反馈和提交贡献,这些都将根据其优点进行考虑。 + +- **社区优先于产品或公司**:维护和发展我们的社区比发布代码或满足赞助商的组织目标更为优先。每位贡献者都是以个人身份参与项目的。 + +- **包容性**:我们通过不同的视角和技能组合来进行创新,这只能在一个受欢迎且互相尊重的环境中实现。 + +- **参与性**:项目中的责任是通过参与获得的,并且有明确的途径从贡献者晋升为领导者。 + +## 成员资格 + +[社区成员资格](./membership.md) 概述了 Kmesh 中不同角色的责任和要求。 + +目前,审批者构成了项目的治理机构。随着社区的发展,这种情况可能会改变,例如通过采用选举产生的指导委员会。 + +## 会议 + +定期会议在 [社区会议](https://github.com/kmesh-net/community/blob/main/README.md#community-meeting) 中有说明。 + +审批者也会召开闭门会议,以讨论安全报告或行为准则违规情况。任何审批者在收到安全问题或行为准则报告后都可以安排此类闭门会议。除被指控违反行为准则的审批者外,所有现任审批者必须被邀请参加此类闭门会议。 + +## 行为准则 + +[行为准则](https://github.com/cncf/foundation/blob/main/code-of-conduct.md) 对社区成员的违规行为将提交至 CNCF 行为准则委员会。如果 CNCF 行为准则委员会需要与项目合作解决问题,审批者将任命一名不涉事的贡献者与其合作。 + +## 安全响应小组 + +审批者将任命一个安全响应小组来处理安全报告。该小组可能仅由审批者委员会自身组成。如果将这一责任委派出去,审批者将任命至少两位贡献者组成小组。审批者至少每年一次会审查分配情况。 + +安全响应小组负责按照 [安全政策](https://github.com/kmesh-net/community/blob/main/security-team/SECURITY.md) 处理所有安全漏洞和安全事件报告。 + +## 投票 + +虽然 Kmesh 的大部分事务通过“懒惰共识”[lazy consensus](https://community.apache.org/committers/lazyConsensus.html) 处理,但审批者有时需要就特定行动或变更进行投票。 +投票可以在 [开发者邮件列表](https://groups.google.com/forum/#!forum/kmesh) 或 [社区仓库 issue](https://github.com/kmesh-net/community/issues/new/choose) 上就安全或行为准则问题进行。投票也可以在 [开发者会议](https://github.com/kmesh-net/community/blob/main/README.md#community-meeting) 上进行。 +任何审批者都可以要求进行投票。 + +大多数投票需要所有审批者的简单多数票才能通过,除非另有说明。三分之二多数票意味着至少需要所有现任审批者中有三分之二赞成。 + +## 修改本章程 + +对本治理及其支持文档的修改,需经审批者 2/3 票通过。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/membership.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/membership.md new file mode 100644 index 00000000..8c169bb0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/community/membership.md @@ -0,0 +1,111 @@ +--- +title: 成员资格 +sidebar_position: 4 +--- + +:::note +此文档会根据 Kmesh 社区的状态和反馈不断更新。 +::: + +本文档概述了 Kmesh 社区中的各角色,以及它们的要求、责任和特权。 + +| 角色 | 要求 | 责任 | 特权 | +| ----------------- | ------------------------------------------------------------------------- | ----------------------------- | ----------------------------------------------------------------- | +| [成员](#成员) | 需获得 2 位审批者推荐、活跃于社区、对 KMesh 有贡献 | 欢迎和指导新贡献者 | KMesh GitHub 组织成员 | +| [审查员](#审查员) | 在子项目中具有审查和作者历史 | 审查社区成员的贡献 | 对相关仓库中特定软件包拥有只读权限 | +| [审批者](#审批者) | 需获得 2 位维护者推荐、在领域内具有丰富经验和知识、对代码和审查有积极贡献 | 审查并批准社区成员的贡献 | 对相关仓库中特定软件包拥有写权限 | +| [维护者](#维护者) | 需获得 2 位所有者推荐、在功能设计/开发和 PR 审查中展现出良好的技术判断 | 参与发布规划以及功能开发/维护 | 对相关仓库拥有最高级写权限,并在仓库的 Maintainers 文件中留下名字 | + +:::note +所有 Kmesh 社区成员都必须遵循 Kmesh 的 [行为准则](https://github.com/cncf/foundation/blob/main/code-of-conduct.md)。 +::: + +## 成员 + +成员通过提交 PR、审查 issue/PR 或在 Slack 和邮件列表上参与社区讨论来积极贡献。 + +### 要求 + +- 获得 2 位审批者的推荐 +- 在其 GitHub 账户上启用 [双因素认证](https://help.github.com/articles/about-two-factor-authentication) +- 对社区有积极贡献,包括: + - 提交 PR + - 审查其他成员的 issue/PR + - 参与社区讨论 + - 参加 Kmesh 社区会议 + +### 责任与特权 + +- 成为 Kmesh GitHub 组织的成员 +- 可被分配处理 issue 和 PR +- 参与分配的 issue 和 PR +- 欢迎和指导新贡献者 +- 帮助新成员为 Kmesh 做出贡献 + +## 审查员 + +审查员负责确保子项目代码的质量和正确性。 + +### 要求 + +- 成员至少需加入 1 个月 +- 作为主要审查员审查过至少 5 个 PR +- 审查或合并过至少 10 个重要 PR +- 熟悉代码库 +- 获得子项目审批者的推荐 +- 未收到其他审批者的异议 +- 通过 PR 被添加至 OWNERS 文件 +- 自我提名或经审批者提名 + +### 责任与特权 + +- 负责项目的质量控制 +- 审查代码的质量、正确性及测试情况 +- 响应审查请求 +- 被分配处理 PR 和在其专业领域内测试 bug +- 在 PR 和 issue 评论中可能获得徽章 + +## 审批者 + +审批者是具有丰富经验、积极审查 PR 并对领域拥有深入了解的成员。 + +### 要求 + +- 获得 2 位维护者的推荐 +- 成员至少需加入 2 个月 +- 审查过大量重要 PR +- 熟悉代码库 + +### 责任与特权 + +- 维护并提升代码质量 +- 接受并审查社区成员提交的 PR +- 批准与其专长相关的贡献 +- 对仓库中特定软件包拥有写权限 +- 指导和辅导其他贡献者 + +## 维护者 + +维护者在功能设计和开发中展现出卓越的技术专长和判断力。 + +### 要求 + +- 获得 2 位所有者的推荐 +- 作为审批者至少 2 个月 +- 经项目所有者提名 +- 在设计/开发中具有出色的技术判断力 + +### 责任与特权 + +- 参与发布规划 +- 维护项目代码质量 +- 确保 API 的兼容性 +- 分析并提议新功能/改进 +- 指导贡献者和审批者 +- 对相关仓库拥有最高级写权限 +- 列在 Maintainers 文件中 +- 领导多个功能的设计和开发 + +:::note +这些角色仅适用于 Kmesh GitHub 组织和仓库。目前,Kmesh 尚未为这些角色建立正式的审查流程,但相关流程将会在不久的将来确立。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md new file mode 100644 index 00000000..92975f57 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl authz 禁用 +sidebar_position: 2 +--- + +```bash +kmeshctl authz disable [podNames...] [flags] +``` + +### 示例 + +```bash +kmeshctl authz disable +kmeshctl authz disable pod1 pod2 +``` + +### 选项 + +```bash + -h, --help help for disable +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json new file mode 100644 index 00000000..4d4613e3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Authz", + "position": 7, + "link": { + "type": "generated-index", + "description": "Manage xdp authz eBPF program for Kmesh's authz offloading" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md new file mode 100644 index 00000000..320ccff4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl authz 启用 +sidebar_position: 1 +--- + +```bash +kmeshctl authz enable [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz enable +kmeshctl authz enable pod1 pod2 +``` + +### Options + +```bash + -h, --help help for enable +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md new file mode 100644 index 00000000..928d22e7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl 授权状态 +sidebar_position: 3 +--- + +```bash +kmeshctl authz status [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz status +kmeshctl authz status pod1 pod2 +``` + +### Options + +```bash + -h, --help help for status +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json new file mode 100644 index 00000000..8d75037c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Waypoint", + "position": 8, + "link": { + "type": "generated-index", + "description": "A group of commands used to manage waypoint configuration" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md new file mode 100644 index 00000000..dba3f201 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md @@ -0,0 +1,36 @@ +--- +title: 配置 +sidebar_position: 1 +--- + +管理 waypoint 配置 + +### 概要 + +一组用于管理 waypoint 配置的命令 + +```bash +kmeshctl waypoint [flags] +``` + +### 示例 + +```bash + # 将 waypoint 应用到当前命名空间 + kmeshctl waypoint apply + + # 以 yaml 格式生成 waypoint + kmeshctl waypoint generate --namespace default + + # 列出特定命名空间中的所有 waypoint + kmeshctl waypoint list --namespace default +``` + +### 选项 + +```bash + -h, --help waypoint 的帮助信息 + --image string waypoint 的镜像 + --name string waypoint 的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md new file mode 100644 index 00000000..f2072977 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md @@ -0,0 +1,42 @@ +--- +title: kmeshctl waypoint apply +sidebar_position: 2 +--- + +将 waypoint 配置应用到集群 + +```bash +kmeshctl waypoint apply [flags] +``` + +### 示例 + +```bash +# 将 waypoint 应用到当前命名空间 +kmeshctl waypoint apply + +# 将 waypoint 应用到特定命名空间并等待其准备就绪 +kmeshctl waypoint apply --namespace default --wait + +# 将 waypoint 应用到特定 pod +kmeshctl waypoint apply -n default --name reviews-v2-pod-waypoint --for workload +``` + +### 选项 + +```bash + --enroll-namespace 如果设置,命名空间将使用 waypoint 名称进行标记 + --for string 为 waypoint 指定流量类型 [all none service workload] + -h, --help apply 命令的帮助信息 + --overwrite 覆盖命名空间中已使用的现有 waypoint + -r, --revision string 用于标记 waypoint 的修订版本 + -w, --wait 等待 waypoint 准备就绪 +``` + +### 从父命令继承的选项 + +```bash + --image string waypoint 的镜像 + --name string waypoint 的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md new file mode 100644 index 00000000..d77e8bd1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md @@ -0,0 +1,41 @@ +--- +title: kmeshctl 航点删除 +sidebar_position: 3 +--- + +从集群中删除 waypoint 配置 + +```bash +kmeshctl waypoint delete [flags] +``` + +### 示例 + +```bash +# 从默认命名空间中删除 waypoint +kmeshctl waypoint delete + +# 按名称删除 waypoint,可以通过 kmeshctl waypoint list 获取名称 +kmeshctl waypoint delete waypoint-name --namespace default + +# 按名称删除多个 waypoint +kmeshctl waypoint delete waypoint-name1 waypoint-name2 --namespace default + +# 删除特定命名空间中的所有 waypoint +kmeshctl waypoint delete --all --namespace default +``` + +### 选项 + +```bash + --all 删除命名空间中的所有 waypoint + -h, --help delete 的帮助 +``` + +### 从父命令继承的选项 + +```bash + --image string waypoint 的镜像 + --name string waypoint 的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md new file mode 100644 index 00000000..c8fe571d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md @@ -0,0 +1,36 @@ +--- +title: kmeshctl waypoint generate +sidebar_position: 4 +--- + +以 YAML 格式生成 waypoint 配置 + +```bash +kmeshctl waypoint generate [flags] +``` + +### 示例 + +```bash +# 以 yaml 格式生成 waypoint +kmeshctl waypoint generate --namespace default + +# 生成一个 waypoint,可以处理默认命名空间中服务的流量 +kmeshctl waypoint generate --for service -n default +``` + +### 选项 + +```bash + --for string 指定 waypoint 的流量类型 [all none service workload] + -h, --help generate 的帮助 + -r, --revision string 标记 waypoint 的修订版本 +``` + +### 从父命令继承的选项 + +```bash + --image string waypoint 的镜像 + --name string waypoint 的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md new file mode 100644 index 00000000..cd538807 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md @@ -0,0 +1,35 @@ +--- +title: kmeshctl waypoint list(列出航点) +sidebar_position: 5 +--- + +列出集群中托管的航点配置 + +```bash +kmeshctl waypoint list [flags] +``` + +### 示例 + +```bash +# 列出特定命名空间中的所有航点 +kmeshctl waypoint list --namespace default + +# 列出集群中的所有航点 +kmeshctl waypoint list -A +``` + +### 选项 + +```bash + -A, --all-namespaces 列出所有命名空间中的所有航点 + -h, --help list 命令的帮助信息 +``` + +### 从父命令继承的选项 + +```bash + --image string 航点的镜像 + --name string 航点的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md new file mode 100644 index 00000000..c517a136 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md @@ -0,0 +1,34 @@ +--- +title: kmeshctl waypoint status(航点状态) +sidebar_position: 6 +--- + +显示所提供命名空间或默认命名空间(如果未提供)中航点的状态 + +```bash +kmeshctl waypoint status [flags] +``` + +### 示例 + +```bash +# 显示默认命名空间中航点的状态 +kmeshctl waypoint status + +# 显示特定命名空间中航点的状态 +kmeshctl waypoint status --namespace default +``` + +### 选项 + +```bash + -h, --help status 命令的帮助信息 +``` + +### 从父命令继承的选项 + +```bash + --image string 航点的镜像 + --name string 航点的名称(默认为 "waypoint") + -n, --namespace string Kubernetes 命名空间 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json new file mode 100644 index 00000000..af93a8a5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Usage", + "position": 3, + "link": { + "type": "generated-index", + "description": "Kmesh command line tools to operate and debug Kmesh" + } +} diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md new file mode 100644 index 00000000..48785c94 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md @@ -0,0 +1,60 @@ +--- +title: Kmeshctl 安装 +sidebar_position: 1 +--- + +## 安装 + +### 1. 从发布二进制文件安装 + +预构建的二进制文件可在我们的[发布页面](https://github.com/kmesh-net/kmesh/releases)上获取。 + +```bash +# 适用于 AMD64 / x86_64 +[ $(uname -m) = x86_64 ] && curl -Lo ./kmeshctl https://github.com/kmesh-net/kmesh/releases/download/v1.0.0/kmeshctl-linux-amd64 +# 适用于 ARM64 +[ $(uname -m) = aarch64 ] && curl -Lo ./kmeshctl https://github.com/kmesh-net/kmesh/releases/download/v1.0.0/kmeshctl-linux-arm64 +chmod +x ./kmeshctl +sudo mv ./kmeshctl /usr/local/bin/kmeshctl +``` + +### 2. 从源代码构建 + +Kmeshctl 仍在快速发展中。如果您想尝试最新功能,可以直接从源代码构建并安装。 + +```bash +# 从 GitHub 克隆源代码 +git clone https://github.com/kmesh-net/kmesh.git + +# 构建并安装 kmeshctl +cd kmesh/ +make kmeshctl +chmod +x ./kmeshctl +sudo mv ./kmeshctl /usr/local/bin/kmeshctl +``` + +## 命令参考 + +### kmeshctl accesslog + +启用或禁用 Kmesh 的访问日志 + +```bash +kmeshctl accesslog [flags] +``` + +**示例** + +```bash +# 启用 Kmesh 的访问日志: +kmeshctl accesslog enable + +# 禁用 Kmesh 的访问日志: +kmeshctl accesslog disable +``` + +**选项** + +```bash + -h, --help accesslog 命令的帮助信息 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-accesslog.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-accesslog.md new file mode 100644 index 00000000..9aa5217e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-accesslog.md @@ -0,0 +1,26 @@ +--- +title: Kmeshctl Accesslog +sidebar_position: 4 +--- + +启用或禁用 Kmesh 的访问日志 + +```bash +kmeshctl accesslog [flags] +``` + +### 示例 + +```bash +# 启用 Kmesh 的访问日志: +kmeshctl accesslog enable + +# 禁用 Kmesh 的访问日志: +kmeshctl accesslog disable +``` + +### 选项 + +```bash + -h, --help help for accesslog +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md new file mode 100644 index 00000000..841d5f39 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md @@ -0,0 +1,26 @@ +--- +title: Kmeshctl Dump(转储) +sidebar_position: 3 +--- + +转储内核原生模式或双引擎模式的配置 + +```bash +kmeshctl dump [flags] +``` + +### 示例 + +```bash +# 内核原生模式: +kmeshctl dump kernel-native + +# 双引擎模式: +kmeshctl dump dual-engine +``` + +### 选项 + +```bash + -h, --help help for dump +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md new file mode 100644 index 00000000..2d2b7bfe --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md @@ -0,0 +1,30 @@ +--- +title: Kmeshctl Log +sidebar_position: 5 +--- + +获取或设置 kmesh-daemon 的日志记录器级别 + +```bash +kmeshctl log [flags] +``` + +### 示例 + +```bash +# 将默认日志记录器的级别设置为 "debug": +kmeshctl log --set default:debug + +# 获取所有日志记录器的名称 +kmeshctl log + +# 获取默认日志记录器的级别: +kmeshctl log default +``` + +### 选项 + +```bash + -h, --help help for log + --set string Set the logger level (e.g., default:debug) +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md new file mode 100644 index 00000000..6621db05 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md @@ -0,0 +1,27 @@ +--- +title: kmeshctl 密钥 +sidebar_position: 6 +--- + +使用密钥为 IPsec 生成密钥配置数据 + +```bash +kmeshctl secret [flags] +``` + +### 示例 + +```bash +# Use secrets to generate secret configuration data for IPsec: + Use --key (or -k) with the AEAD algorithm rfc4106(gcm(aes)); the key must be 36 characters long (32 for key and 4 for salt). + A hexadecimal dump is required when the key is entered. + e.g.: kmeshctl secret --key=$(dd if=/dev/urandom count=36 bs=1 2>/dev/null | xxd -p -c 64) + e.g.: kmeshctl secret -k=$(echo -n "{36-character user-defined key here}" | xxd -p -c 64) +``` + +### 选项 + +```bash + -h, --help help for secret + -k, --key string key of the encryption +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md new file mode 100644 index 00000000..0bc461f4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md @@ -0,0 +1,26 @@ +--- +title: Kmeshctl 版本 +sidebar_position: 2 +--- + +打印构建版本信息 + +```bash +kmeshctl version [flags] +``` + +### 示例 + +```bash +# 显示 kmeshctl 的版本 +kmeshctl version + +# 显示特定 Kmesh 守护进程的版本信息 +kmeshctl version +``` + +### 选项 + +```bash + -h, --help help for version +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/e2e-test.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/e2e-test.md new file mode 100644 index 00000000..76e7d89e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/e2e-test.md @@ -0,0 +1,108 @@ +--- +title: 运行 E2E 测试 +sidebar_position: 2 +--- + +端到端(E2E)测试是现代软件开发中的一个关键组成部分,旨在模拟用户在整个应用程序中的交互,以确保所有组件和集成能够无缝协作。通过引入 E2E 测试,我们可以验证代码更改不会干扰现有功能,从而在系统演进过程中保持其完整性和可靠性。 + +## 先决条件 + +用户需要安装以下组件: + +- Go +- Docker +- Kubectl + +以下组件将在使用 shell 脚本时自动安装: + +- Kind +- Helm +- Istioctl + +## 使用方法 + +要运行 E2E 测试,请执行位于 `./test/e2e` 目录中的 `run_test.sh` 脚本。该脚本将自动完成以下任务: + +1. **安装依赖项:** 安装 Kind、Helm 和 Istioctl 等工具。 +2. **部署本地镜像注册表:** 使用 Docker 容器作为本地镜像注册表。 +3. **构建并推送 Kmesh 镜像:** 构建自定义 Kmesh Docker 镜像并将其推送到本地注册表。 +4. **部署 Kubernetes 集群、Istio 和 Kmesh:** 这些组件是测试所需的,在此步骤中完成设置。 +5. **部署测试应用程序并执行 E2E 测试。** + +## 命令行标志 + +在本地测试时,您可能希望跳过某些设置步骤以节省时间,特别是在初始设置完成后。以下标志可用于自定义测试执行: + +- **--skip-install-dep**:跳过依赖项的安装。 +- **--skip-build**:跳过构建并推送 Kmesh 镜像到本地镜像注册表。 +- **--skip-setup**:跳过部署 Kubernetes 集群、Istio 和 Kmesh。 +- **--only-run-tests**:跳过所有其他步骤,仅专注于部署测试应用程序和运行 E2E 测试。 +- **--cluster**:允许通过名称指定一个预先存在的 KinD 集群。 +- **--ipv6**:启用创建具有 IPv6 网络的 KinD 集群并在其上运行 E2E 测试。 +- **--cleanup**:在测试完成后清理 KinD 集群和本地注册表。 +- **--skip-cleanup-apps**:在测试执行后跳过清理测试应用程序。 +- 直接使用 **go test** 命令行参数运行测试 + +### 示例命令 + +#### 完整测试运行(首次) + +```bash +./test/e2e/run_test.sh +``` + +使用此命令进行初始设置和测试运行,以确保所有配置正确。 + +#### 后续测试运行(跳过所有设置并仅运行测试) + +```bash +./test/e2e/run_test.sh --only-run-tests +``` + +您可能需要不同类型的测试。 + +#### 指定一个预先存在的 KinD 集群 + +```bash +./test/e2e/run_test.sh --cluster +``` + +#### 创建一个 IPv6 KinD 集群并运行测试 + +```bash +./test/e2e/run_test.sh --ipv6 +``` + +在某些情况下,您可能希望在测试后清理某些资源,而在其他情况下,您可能希望跳过清理测试应用程序以供进一步使用。 + +#### 在测试后清理 KinD 集群和 Docker 注册表 + +```bash +./test/e2e/run_test.sh --cleanup +``` + +#### 在测试后跳过清理测试应用程序 + +```bash +./test/e2e/run_test.sh --skip-cleanup-apps +``` + +您还可以在运行测试时直接使用 **go test** 命令行参数。例如,您可以过滤特定的测试用例,或直接从命令行控制测试过程的其他方面。 + +#### 选择特定的测试用例 + +```bash +./test/e2e/run_test.sh --only-run-tests -run "TestServices" +``` + +#### 控制测试详细程度 + +```bash +./test/e2e/run_test.sh -v +``` + +#### 重复测试用例多次 + +```bash +./test/e2e/run_test.sh -count=3 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/unit-test.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/unit-test.md new file mode 100644 index 00000000..c6867abc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/Tests/unit-test.md @@ -0,0 +1,57 @@ +--- +title: 运行单元测试 +sidebar_position: 1 +--- + +# 运行单元测试 + +直接在操作系统中编译 Kmesh 需要特定的 [OS 版本](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md)。因此,为了让所有操作系统都能运行 Kmesh 的单元测试(UT),Kmesh 提供了两种方法。一种是在 Docker 中运行 Go 单元测试,另一种是在本地运行 Go 单元测试。 + +不支持的内核版本的开发者可以通过脚本在 Docker 中运行 Go 单元测试。支持版本的开发者可以通过脚本在本地运行 Go 单元测试。 + +```sh +cd $(Kmesh root directory) + +# 通过 Docker 运行 Kmesh 单元测试 +./hack/run-ut.sh --docker + +# 在本地运行 Kmesh 单元测试 +./hack/run-ut.sh --local +``` + +或者,您可以通过 `make test` 执行测试: + +```sh +# 通过 Docker 运行 Kmesh 单元测试 +make test RUN_IN_CONTAINER=1 + +# 在本地运行 Kmesh 单元测试 +make test RUN_IN_CONTAINER=0 +``` + +## 单元测试 + +本节描述 Kmesh 的单元测试设置,以便开发人员可以不使用脚本运行单元测试。 + +由于 Kmesh 使用 eBPF,您在运行与 Kmesh 相关的单元测试时需要设置一些环境变量。 + +```sh +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$ROOT_DIR/api/v2-c:$ROOT_DIR/bpf/deserialization_to_bpf_map +export PKG_CONFIG_PATH=$ROOT_DIR/mk +``` + +设置 `LD_LIBRARY_PATH` 以便系统可以找到 .so 文件。 + +设置 `PKG_CONFIG_PATH` 以便系统可以找到 Kmesh 编译的 .pc 文件。 + +除此之外,您还可能遇到 C 头文件未找到的错误。可以通过设置 `C_INCLUDE_PATH` 来解决此类错误。Kmesh 所需的头文件保存在 [bpf](https://github.com/kmesh-net/kmesh/tree/main/bpf) 文件夹中。 + +注意 **多个头文件** 问题。 + +除了上述问题,由于 Kmesh 单元测试使用 gomonkey,在 Go 编译优化过程中可能会出现 monkey 的函数被内联的情况。 + +我们可以通过在 go test 执行时添加以下参数来解决这个问题: + +```bash +-gcflags="all=-N -l" +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/_category_.json new file mode 100644 index 00000000..3032d2ab --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Developer Guide", + "position": 5, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/build-guide.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/build-guide.md new file mode 100644 index 00000000..41e646f1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/build-guide.md @@ -0,0 +1,133 @@ +--- +sidebar_position: 1 +title: 如何构建 +--- + +Kmesh 需要在具有 Kmesh 内核增强功能的 Linux 环境中编译和构建。目前,Kmesh 可以在多个 OS 版本中编译和运行,具体 OS 版本请参见 [Kmesh 支持系统](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md)。 + +## 构建 + +### 先决条件 + +- 安装 Docker 引擎 + + ```sh + sudo apt-get update + (可选)sudo apt-get remove docker docker-engine docker.io + sudo apt install docker.io + ``` + + 您可以检查 Docker 版本以确保 Docker 已安装。 + + ```sh + docker version + Client: Docker Engine - Community + Version: 26.0.1 + API version: 1.45 + Go version: go1.21.9 + Git commit: d260a54 + Built: Thu Apr 11 10:53:21 2024 + OS/Arch: linux/amd64 + Context: default + + Server: Docker Engine - Community + Engine: + Version: 26.0.1 + API version: 1.45 (minimum version 1.24) + Go version: go1.21.9 + Git commit: 60b9add + Built: Thu Apr 11 10:53:21 2024 + OS/Arch: linux/amd64 + Experimental: false + containerd: + Version: 1.6.31 + GitCommit: e377cd56a71523140ca6ae87e30244719194a521 + runc: + Version: 1.1.12 + GitCommit: v1.1.12-0-g51d5e94 + docker-init: + Version: 0.19.0 + GitCommit: de40ad0 + ``` + +- 下载 Kmesh-build 镜像 + + 要编译 Kmesh 镜像,您需要准备 Kmesh 源代码和 Kmesh-build 镜像。可以使用以下命令获取镜像: + + ```sh + docker pull ghcr.io/kmesh-net/kmesh-build-x86:latest + ``` + + 注意:`Kmesh-build` 镜像需要与源代码版本匹配。 + +### 从源代码构建 Kmesh + +从 GitHub 克隆源代码。 + +```sh +git clone https://github.com/kmesh-net/kmesh.git +``` + +代码编译 + +- 通过 build-image 编译 Kmesh + + ```sh + cd kmesh/ + make build + ``` + +- 通过脚本编译 Kmesh + + Kmesh 也提供通过脚本编译的方式 + + ```sh + [root@dev] ./kmesh_compile.sh + ``` + + 注意,如果您使用脚本编译,需要确保您的 OS 系统版本是 [Kmesh 支持系统](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md) 中的一个! + +Kmesh 编译完成后,构建产物将输出到 `out` 目录。 + +```bash +ls out/amd64/ +kmesh-daemon libbpf.so libbpf.so.0.8.1 libkmesh_deserial.so libprotobuf-c.so.1 mdacore +kmesh-cni libboundscheck.so libbpf.so.0 libkmesh_api_v2_c.so libprotobuf-c.so libprotobuf-c.so.1.0.0 +``` + +### 构建 Docker 镜像 + +在 Kmesh 源代码目录中执行 `make docker`。 + +用户可以指定构建参数,如下例所示: + +```sh +用户自定义 HUB、TARGET、TAG 值。如果未指定,将使用默认值。 +HUB=ghcr.io/kmesh-net +TARGET=kmesh +TAG= #git sha + +[root@dev docker] make docker +... +Successfully tagged ghcr.io/kmesh-net/kmesh:b68790eb07830e757f4ce6d1c478d0046ee79730 + +[root@dev docker] make docker HUB=ghcr.io/kmesh-net TARGET=kmesh TAG=latest +... +Successfully tagged ghcr.io/kmesh-net/kmesh:latest +``` + +检查本地镜像仓库中现有的 Kmesh 镜像: + +```sh +[root@dev docker]# docker images ls +REPOSITORY TAG IMAGE ID CREATED SIZE +ghcr.io/kmesh-net/kmesh latest 71aec5898c44 About an hour ago 506MB +``` + +### 编译清理 + +您可以使用以下命令清理二进制文件。 + +```sh +[root@dev] make clean +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/traffic-spilt.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/traffic-spilt.md new file mode 100644 index 00000000..007d01b7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/developer-guide/traffic-spilt.md @@ -0,0 +1,104 @@ +--- +sidebar_position: 2 +title: 流量分割 +--- + +### 开始之前 + +#### 在 Kernel-Native 模式下安装 Kmesh + +1. 导航至 [快速入门](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md) 文档 +2. 在标题为 `更改 Kmesh 启动模式` 的部分 +3. 打开配置文件:`deploy/charts/kmesh-helm/values.yaml` +4. 将 `--mode=dual-engine` 替换为 `--mode=kernel-native` + +此配置更改是流量分割功能正常工作的必要条件。 + +#### 部署示例应用程序 + +```shell +[root@master kmesh]# kubectl apply -f samples/sleep/sleep.yaml -n tcp-echo-test +[root@master kmesh]# kubectl apply -f samples/tcp-echo/tcp-echo-services.yaml -n tcp-echo-test +[root@master kmesh]# kubectl apply -f samples/tcp-echo/tcp-echo-virtualservice.yaml -n tcp-echo-test +``` + +### 应用基于权重的负载均衡 + +1. 让 Kmesh 管理 Pod 的流量 + + ```shell + [root@master test]# kubectl label ns default istio.io/dataplane-mode=Kmesh + ``` + +2. 通过发送一些 TCP 流量来确认 `tcp-echo` 服务正在运行。 + + ```shell + ## 获取 tcp-echo 服务地址 + [root@master test]# kubectl get svc | grep tcp- + tcp-echo ClusterIP 10.96.128.249 9000/TCP,9001/TCP 43h + [root@master test]# for i in {1..20}; do kubectl exec sleep-78ff5975c6-cm8hd -c sleep -- sh -c "(date; sleep 1) | nc 10.96.128.249:9000;" done + two Sat Jul 6 08:46:45 UTC 2024 + two Sat Jul 6 08:46:46 UTC 2024 + one Sat Jul 6 08:46:47 UTC 2024 + one Sat Jul 6 08:46:48 UTC 2024 + two Sat Jul 6 08:46:49 UTC 2024 + two Sat Jul 6 08:46:51 UTC 2024 + two Sat Jul 6 08:46:52 UTC 2024 + one Sat Jul 6 08:46:53 UTC 2024 + two Sat Jul 6 08:46:54 UTC 2024 + two Sat Jul 6 08:46:55 UTC 2024 + one Sat Jul 6 08:46:56 UTC 2024 + one Sat Jul 6 08:46:57 UTC 2024 + two Sat Jul 6 08:46:58 UTC 2024 + one Sat Jul 6 08:47:00 UTC 2024 + two Sat Jul 6 08:47:01 UTC 2024 + one Sat Jul 6 08:47:02 UTC 2024 + two Sat Jul 6 08:47:03 UTC 2024 + one Sat Jul 6 08:47:04 UTC 2024 + one Sat Jul 6 08:47:05 UTC 2024 + two Sat Jul 6 08:47:06 UTC 2024 + ``` + +### 转储配置信息 + +```shell +[root@master kmesh]# ./kmeshctl dump kmesh-5f4fm kernel-native +``` + +转储配置后,我们可以看到策略是负载均衡。 + +```json +{ + "name": "outbound|9001||tcp-echo.default.svc.cluster.local", + "connectTimeout": 10, + "lbPolicy": "LEAST_REQUEST", + "loadAssignment": { + "clusterName": "outbound|9001||tcp-echo.default.svc.cluster.local", + "endpoints": [ + { + "lbEndpoints": [ + { + "address": { + "port": 10531, + "ipv4": 469890058 + } + }, + { + "address": { + "port": 10531, + "ipv4": 453112842 + } + } + ], + "loadBalancingWeight": 2 + } + ] + }, + "circuitBreakers": { + "maxConnections": 4294967295, + "maxPendingRequests": 4294967295, + "maxRequests": 4294967295, + "maxRetries": 4294967295 + } +} +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/_category_.json new file mode 100644 index 00000000..a1f7c1ae --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Performance", + "position": 4, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/fortio_performance_test.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/fortio_performance_test.png new file mode 100644 index 00000000..893e4af7 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/fortio_performance_test.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/perf_network.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/perf_network.png new file mode 100644 index 00000000..7951459c Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/perf_network.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test1.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test1.png new file mode 100644 index 00000000..6321b3a5 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test1.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test2.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test2.png new file mode 100644 index 00000000..c92df042 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test2.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test3.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test3.png new file mode 100644 index 00000000..e82a8c06 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test3.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_env.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_env.png new file mode 100644 index 00000000..19e1bd0b Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_env.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_memory.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_memory.png new file mode 100644 index 00000000..b21e2c34 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_memory.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result1.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result1.png new file mode 100644 index 00000000..c103cb4d Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result1.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result2.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result2.png new file mode 100644 index 00000000..958e1e3c Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result2.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result3.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result3.png new file mode 100644 index 00000000..f27cdb9e Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result3.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result4.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result4.png new file mode 100644 index 00000000..55c20067 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/images/resource_test_result4.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/performance.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/performance.md new file mode 100644 index 00000000..70f18d31 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/performance.md @@ -0,0 +1,48 @@ +--- +title: Kmesh 性能 +sidebar_position: 1 +--- + + +## 可观测性集成 + +Kmesh 通过与行业标准可观测性平台集成,提供全面的监控能力: + +- **Prometheus**:收集并存储 Kmesh 性能和操作的指标 +- **Grafana**:通过可定制的仪表板可视化 Kmesh 指标 +- **Jaeger**:启用分布式追踪以分析服务网格流量模式 + +这些集成有助于实时监控 Kmesh 的性能指标、资源消耗和流量模式。 + +## 测试网络设置 + +![性能网络图](./images/perf_network.png) + +## 测试方法 + +### 测试工具 + +Kmesh 使用两个主要测试工具: + +- **Fortio**:一个微服务负载测试工具,用于测量: + - 延迟(TP90,TP99) + - 吞吐量(QPS) +- **Dstat**:一个系统监控工具,用于在测试期间跟踪 CPU 使用情况 + +### 测试方法 + +通过使用并发连接数作为变量参数来测试一组 `fortio` 性能数据,并在测试期间收集 CPU 使用情况。[测试脚本](https://github.com/kmesh-net/kmesh/test/performance/)已被归档。 + +## 运行测试 + +```shell +#准备测试环境 +[root@perf]# ./fortio_perf.sh +# 在目录中生成测试结果的 CSV 表格。 +[root@perf]# ll +-rw-r--r--. 1 root root 6.1K Nov 5 17:39 fortio_perf_test.csv +``` + +## 性能结果 + +![性能测试结果](./images/fortio_performance_test.png) diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/resource-consumption.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/resource-consumption.md new file mode 100644 index 00000000..60746f49 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/performance/resource-consumption.md @@ -0,0 +1,220 @@ +--- +title: Kmesh 资源消耗 +sidebar_position: 2 +--- + +# Kmesh 资源消耗 + +## 背景信息 + +eBPF 程序在执行过程中会消耗 CPU 和内存资源。为了更好地了解 Kmesh 在不同负载下的资源消耗情况,我们进行了一系列 CPU 和内存压力测试。这些测试旨在评估 Kmesh 在实际使用场景中的资源消耗极限。 + +**注意:本文档基于 Kmesh 0.4 内核原生模式** + +## 环境设置 + +![资源测试环境](./images/resource_test_env.png) + +| 组件 | 版本/详情 | +| ------------- | --------------------------------------------------------------------------------------------------------------------- | +| K8S | v1.27 | +| Kmesh | 0.4 内核原生模式 | +| 内核 | 5.10 | +| 节点 | 8U16G | +| 测试工具 | fortio | +| 指标收集 | [bpftop](https://github.com/Netflix/bpftop), [inspektor-gadget](https://github.com/inspektor-gadget/inspektor-gadget) | + +## 测试用例 1:带 CPU 限制的 POD + +### 场景 1.1:单个带 CPU 限制的应用程序 + +![资源测试 1](./images/resource_test1.png) + +我们为应用程序 A(App A)设置了 1 个 CPU 的限制,并收集了 Kmesh eBPF 的 CPU 消耗数据。 + +:::note +系统共有 8 个核心,CPU 限制为 1,POD 最多可消耗总 CPU 的 12.5%。 +::: + +**测试步骤:** + +1. 使用 fortio 客户端生成负载: + + ```bash + # !/bin/bash + + client_address=`kubectl get pod | grep fortio-client | awk {'print $1'}` + echo "$client_address" | xargs -P 0 -I {} kubectl exec -it {} -- fortio load -quiet -c 1500 -t 100s -qps 0 -keepalive=false fortio-server.default.svc.cluster.local:80 + ``` + +2. 使用 bpftop 收集 CPU 使用率: + + ```bash + ./bpftop + ``` + +**测试结果:** + +![资源测试结果 1](./images/resource_test_result1.png) + +图中显示的 12.99% 表示消耗了一个 CPU 核心的 12.99%。 + +**结论:** +当 App A 完全利用一个 CPU 核心时,eBPF 程序消耗了总 CPU 的 1.73%(即一个 CPU 核心的 13.9%,相当于 8 个核心的 1.73%),低于 POD 的 CPU 限制 12.5%。这表明 Kmesh eBPF 的 CPU 消耗受限于 POD 的 CPU 限制,或者其本身资源需求较小。 + +### 场景 1.2:多个带 CPU 限制的应用程序 + +![资源测试 2](./images/resource_test2.png) + +我们部署了 4 个 App A 实例,每个实例的 CPU 限制为 250m,4 个实例总计 1 个 CPU。 + +**测试结果:** + +![资源测试结果 2](./images/resource_test_result2.png) + +图中显示的 13.42% 表示消耗了一个 CPU 核心的 13.42%。 + +**结论:** +当 App A 完全利用 1 个 CPU 时,eBPF 程序消耗了总 CPU 的 1.81%,仍低于 POD CPU 限制的 12.5%。这进一步验证了 eBPF 的 CPU 消耗受 POD 限制约束。 + +### 场景 1.3:修改 eBPF 代码以增加 CPU 使用率 + +我们修改了 eBPF 代码,通过添加循环降低性能,以观察其是否会超过 POD 的 CPU 限制。 + +**实现:** +在 Kmesh eBPF 代码中添加了 for 循环: + +```c +SEC("cgroup/connect4") +int cgroup_connect4_prog(struct bpf_sock_addr *ctx) +{ + struct kmesh_context kmesh_ctx = {0}; + kmesh_ctx.ctx = ctx; + kmesh_ctx.orig_dst_addr.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_ip.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_port = ctx->user_port; + + if (handle_kmesh_manage_process(&kmesh_ctx) || !is_kmesh_enabled(ctx)) { + return CGROUP_SOCK_OK; + } + + // 添加 for 循环以增加 CPU 使用率 + int i; + for (i = 0; i < 65535; i++) { + bpf_printk("increase cpu usage"); + } + + int ret = sock4_traffic_control(ctx); + return CGROUP_SOCK_OK; +} +``` + +**测试结果:** + +![资源测试结果 3](./images/resource_test_result3.png) + +当 App A 完全利用 1 个 CPU 时,eBPF 程序消耗了总 CPU 的 12.1%,仍低于 POD CPU 限制的 12.5%。多轮测试显示,eBPF 的 CPU 消耗始终未超过限制。 + +**结论:** +Kmesh eBPF 与应用程序共享 POD 的 CPU 限制,其 CPU 消耗受限于 POD 的设定。 + +## 测试用例 2:无 POD CPU 限制的场景 + +### 场景 2.1:测试 eBPF CPU 消耗(无限制) + +![资源测试 3](./images/resource_test3.png) + +我们创建了 8 个 App A 实例,无 CPU 限制。逐渐增加负载生成进程数量,直到节点 CPU 使用率达到 100%,然后记录 Kmesh eBPF 的 CPU 使用率。 + +**测试结果(8 核 CPU 共 8000m):** + +| 线程数 | App A CPU 使用率 | eBPF CPU 使用率 | +| ------- | --------------- | -------------- | +| 100 | 12.3% | 1% | +| 500 | 35% | 4.1% | +| 1000 | 61.7% | 8.8% | +| 3000 | 67% | 9.5% | + +在 3000 个并发进程时,节点 CPU 使用率达到 100%。此时,App A 消耗 67% 的 CPU,Kmesh eBPF 消耗约 9.5%。 + +**结论:** + +- App A 的 CPU 消耗远高于 eBPF,难以使 eBPF 过载。在 fortio 测试场景中,Kmesh eBPF 最多消耗 9.5% 的 CPU。 +- eBPF 的最大 CPU 消耗需进一步测试。 + +### 场景 2.2:eBPF CPU 压力测试 + +根据 [eBPF 官方文档](https://ebpf-docs.dylanreimerink.nl/linux/concepts/verifier/),eBPF 程序具有安全机制,可检测无限循环并限制 for 循环迭代次数。在内核版本 5.10 中,for 循环最多支持 65,535 次迭代。 + +我们在代码中添加了 65,535 次迭代进行测试: + +```c +SEC("cgroup/connect4") +int cgroup_connect4_prog(struct bpf_sock_addr *ctx) +{ + struct kmesh_context kmesh_ctx = {0}; + kmesh_ctx.ctx = ctx; + kmesh_ctx.orig_dst_addr.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_ip.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_port = ctx->user_port; + + if (handle_kmesh_manage_process(&kmesh_ctx) || !is_kmesh_enabled(ctx)) { + return CGROUP_SOCK_OK; + } + + // 添加 for 循环以增加 CPU 使用率 + int i; + for (i=0;i<65535;i++) { + bpf_printk("increase cpu usage"); + } + + int ret = sock4_traffic_control(ctx); + return CGROUP_SOCK_OK; +} +``` + +**测试结果:** + +![资源测试结果 4](./images/resource_test_result4.png) + +当节点 CPU 使用率达到 100% 时,Kmesh eBPF 消耗了约 99.3% 的 CPU。此测试运行 10 分钟,期间内核和集群服务保持稳定。 + +**结论:** +在最大迭代次数下,eBPF 可消耗几乎全部 CPU 资源,但内核安全机制确保系统稳定运行。 + +## Kmesh eBPF 内存限制测试 + +根据 [官方文档](https://ebpf-docs.dylanreimerink.nl/linux/concepts/resource-limit/),eBPF 的内存消耗有上限,由 cGroup 的 `memory.max` 设置控制。但 Kmesh 当前实现中,内存于启动时分配,运行时不增加。 + +### 测试 1:不同服务数量下的内存使用 + +我们在集群中创建了 1、100 和 1000 个服务,使用 [inspektor-gadget](https://github.com/inspektor-gadget/inspektor-gadget) 记录 eBPF 内存消耗。 + +**监控命令:** + +```bash +kubectl gadget top ebpf +``` + +![资源测试内存](./images/resource_test_memory.png) + +**测试结果:** + +| 服务数量 | eBPF 内存使用 | +| -------- | ------------ | +| 1 | 23 MB | +| 100 | 23 MB | +| 1000 | 23 MB | + +**结论:** +Kmesh eBPF 的内存消耗始终为 23 MB,与服务数量无关。 + +### 测试 2:负载下的内存使用 + +我们在集群中创建了一个服务(App A),生成负载并观察 eBPF 内存消耗。 + +**测试结果:** +Kmesh eBPF 内存消耗保持在 23 MB,不随负载变化。 + +**总结:** +Kmesh 在 CPU 和内存消耗方面表现稳定。CPU 消耗受 POD 限制约束,无限制时可达高负载但系统仍稳定;内存消耗固定为 23 MB,不受服务数量或负载影响。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/_category_.json new file mode 100644 index 00000000..7ec8de9c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Setup", + "position": 2, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/develop-with-kind.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/develop-with-kind.md new file mode 100644 index 00000000..a668d4a2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/develop-with-kind.md @@ -0,0 +1,167 @@ +--- +title: 使用 Kind 进行部署/开发 +sidebar_position: 2 +--- + +# 使用 Kind 部署/开发 + +[Kind](https://github.com/kubernetes-sigs/kind) 是一种方便的工具,用于在本地快速部署 kubernetes 集群。我们可以使用 `kind` 创建 `istio` 集群并部署 `kmesh`。 + +## 在 Kind 中部署 Kmesh + +让我们从设置所需环境开始。您可以按照以下步骤操作: + +### 安装 kind + +安装 `kind` 非常简单,因为它只是一个二进制文件。您可以根据 [github 发布页面](https://github.com/kubernetes-sigs/kind/releases) 上的版本和架构选择正确的文件。以 `linux` + `amd64` 为例: + +```shell +wget -O kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-linux-amd64 +chmod +x kind +mv kind /usr/bin/ +``` + +### 使用 kind 创建 Kubernetes 集群 + +您可以参考 [istio 官方文档](https://istio.io/latest/docs/setup/platform-setup/kind/)。 + +如果您想指定多个工作节点或节点镜像,可以: + +```shell +kind create cluster --image=kindest/node:v1.30.0 --config=- < **注意**:要使用路径点,您需要安装 Kubernetes Gateway API CRD,大多数 Kubernetes 集群默认不安装: + +```shell +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +### 仅安装 Istiod + +按照上述步骤安装环境模式 istio 将安装额外的 istio 组件。 + +下面提供仅安装 `istiod` 作为 Kmesh 控制平面的过程。 + +#### 安装 Istio CRD + +```shell +helm repo add istio https://istio-release.storage.googleapis.com/charts +helm repo update +``` + +使用发布名称 `istio-base` 安装图表: + +```shell +kubectl create namespace istio-system +helm install istio-base istio/base -n istio-system +``` + +#### 安装 Istiod + +使用发布名称 `istiod` 安装图表: + +```shell +helm install istiod istio/istiod --namespace istio-system --version 1.24.0 --set pilot.env.PILOT_ENABLE_AMBIENT=true +``` + +> **重要:** 必须设置 `pilot.env.PILOT_ENABLE_AMBIENT=true`。否则 Kmesh 将无法与 istiod 建立 grpc 链接! 如果想要使用 Waypoint 功能,您的 istiod 版本应该为 1.23~1.25。 + +安装 istiod 后,是时候安装 Kubernetes Gateway API CRD 了。 + +```shell +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +## 安装 Kmesh + +我们提供多种安装 Kmesh 的方式: + +### 选项 1:从 Helm 安装 + +```shell +helm install kmesh ./deploy/charts/kmesh-helm -n kmesh-system --create-namespace +``` + +### 选项 2:从 Yaml 安装 + +```shell +kubectl create namespace kmesh-system +kubectl apply -f ./deploy/yaml/ +``` + +您可以使用以下命令确认 Kmesh 的状态: + +```shell +kubectl get pod -n kmesh-system +NAME READY STATUS RESTARTS AGE +kmesh-v2frk 1/1 Running 0 18h +``` + +查看 Kmesh 服务的运行状态: + +```log +time="2024-04-25T13:17:40Z" level=info msg="bpf Start successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="controller Start successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="dump StartServer successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="start write CNI config\n" subsys="cni installer" +time="2024-04-25T13:17:40Z" level=info msg="kmesh cni use chained\n" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="Copied /usr/bin/kmesh-cni to /opt/cni/bin." subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="kubeconfig either does not exist or is out of date, writing a new one" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="wrote kubeconfig file /etc/cni/net.d/kmesh-cni-kubeconfig" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="cni config file: /etc/cni/net.d/10-kindnet.conflist" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="command Start cni successful" subsys=manager +``` + +## 验证安装 + +安装 Kmesh 后,验证所有组件是否正常运行: + +### 1. 验证核心组件 + +检查 Kmesh pod 状态: + +```shell +kubectl get pod -n kmesh-system +NAME READY STATUS RESTARTS AGE +kmesh-v2frk 1/1 Running 0 18h +``` + +检查 Istio 组件: + +```shell +kubectl get pods -n istio-system +NAME READY STATUS RESTARTS AGE +istiod-5659cfbd55-9s92d 1/1 Running 0 18h +``` + +### 2. 验证 Kmesh 服务日志 + +检查成功初始化消息: + +```shell +kubectl logs -n kmesh-system $(kubectl get pods -n kmesh-system -o jsonpath='{.items.metadata.name}') +``` + +查找这些关键消息: + +- "bpf Start successful" +- "controller Start successful" +- "dump StartServer successful" +- "command Start cni successful" + +### 3. 验证 CNI 配置 + +检查 CNI 二进制安装: + +```shell +ls -l /opt/cni/bin/kmesh-cni +``` + +验证 CNI 配置: + +```shell +cat /etc/cni/net.d/kmesh-cni-kubeconfig +``` + +### 4. 验证 Pod 集成 + +部署测试 pod 并验证 Kmesh 注解: + +```shell +kubectl describe po | grep Annotations +Annotations: kmesh.net/redirection: enabled +``` + +### 5. 验证服务连接 + +使用 sleep pod 测试服务访问: + +```shell +kubectl exec sleep-7656cf8794-xjndm -c sleep -- curl -IsS "http://httpbin:8000/status/200" +``` + +预期响应应显示 HTTP 200 OK 状态。 + +## 更改 Kmesh 启动模式 + +Kmesh 支持两种启动模式:`dual-engine` 和 `kernel-native`。 + +具体使用的模式在 deploy/charts/kmesh-helm/values.yaml 中定义,我们可以在该文件中修改启动参数。 + +```yaml +...... + containers: + kmeshDaemonArgs: "--mode=dual-engine --enable-bypass=false" +...... +``` + +我们可以使用以下命令进行修改: + +```shell +sed -i 's/--mode=dual-engine/--mode=kernel-native/' deploy/charts/kmesh-helm/values.yaml +``` + +## 部署示例应用 + +Kmesh 可以管理带有标签 `istio.io/dataplane-mode=Kmesh` 的命名空间中的 pod,同时该 pod 不应具有 `istio.io/dataplane-mode=none` 标签。 + +```shell +# 为指定命名空间启用 Kmesh +kubectl label namespace default istio.io/dataplane-mode=Kmesh +``` + +应用以下配置以部署 sleep 和 httpbin: + +```shell +kubectl apply -f ./samples/httpbin/httpbin.yaml + +kubectl apply -f ./samples/sleep/sleep.yaml +``` + +检查应用状态: + +```shell +kubectl get pod +NAME READY STATUS RESTARTS AGE +httpbin-65975d4c6f-96kgw 1/1 Running 0 3h38m +sleep-7656cf8794-8tp9n 1/1 Running 0 3h38m +``` + +您可以通过查看 pod 的注解来确认 pod 是否由 Kmesh 管理。 + +```shell +kubectl describe po httpbin-65975d4c6f-96kgw | grep Annotations + +Annotations: kmesh.net/redirection: enabled +``` + +## 测试服务访问 + +在应用程序由 Kmesh 管理后,我们可以测试它们是否仍能成功通信。 + +```shell +kubectl exec sleep-7656cf8794-xjndm -c sleep -- curl -IsS "http://httpbin:8000/status/200" + +HTTP/1.1 200 OK +Server: gunicorn/19.9.0 +Date: Sun, 28 Apr 2024 07:31:51 GMT +Connection: keep-alive +Content-Type: text/html; charset=utf-8 +Access-Control-Allow-Origin: * +Access-Control-Allow-Credentials: true +Content-Length: 0 +``` + +注意:10.244.0.21 是 httpbin 的 IP + +## 清理 + +如果您不想再使用 Kmesh 管理应用程序,可以从命名空间中移除标签。 + +```shell +kubectl label namespace default istio.io/dataplane-mode- +kubectl delete pod httpbin-65975d4c6f-96kgw sleep-7656cf8794-8tp9n +kubectl describe pod httpbin-65975d4c6f-h2r99 | grep Annotations + +Annotations: +``` + +### 删除 Kmesh + +如果您使用 helm 安装了 Kmesh: + +```shell +helm uninstall kmesh -n kmesh-system +kubectl delete ns kmesh-system +``` + +如果您使用 yaml 安装了 Kmesh: + +```shell +kubectl delete -f ./deploy/yaml/ +``` + +要移除 sleep 和 httpbin 应用程序: + +```shell +kubectl delete -f samples/httpbin/httpbin.yaml +kubectl delete -f samples/sleep/sleep.yaml +``` + +如果您安装了 Gateway API CRD,请移除它们: + +```shell +kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl delete -f - +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/troubleshooting.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/troubleshooting.md new file mode 100644 index 00000000..0b35543c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/troubleshooting.md @@ -0,0 +1,182 @@ +--- +title: 安装故障排除指南 +sidebar_position: 4 +--- + +## 常见安装问题 + +### 端口冲突 + +在部署Kmesh时,您可能会遇到端口冲突,尤其是默认使用的端口15006。 + +| 错误代码 | 描述 | 影响 | 解决方案 | +| --------------- | ------------------------- | ------------------------ | --------------------------------- | +| ERR_PORT_IN_USE | 端口15006已被使用 | 阻止Kmesh启动 | 更改端口或释放现有端口 | +| MISSING_DEP | 缺少libbpf依赖 | BPF功能不可用 | 安装libbpf ≥0.8 | +| CNI_CONFLICT | CNI插件冲突 | 网络设置失败 | 验证CNI配置 | + +## 详细解决方案 + +### 端口冲突解决 + +如果您遇到**ERR_PORT_IN_USE**,请按照以下步骤操作: + +1. **诊断冲突**: + + ```shell + # 检查什么正在使用端口15006 + sudo lsof -i :15006 + + # 对于systemd服务 + sudo ss -lptn 'sport = :15006' + ``` + +2. **解决选项**: + + a. 更改Kmesh端口: + + ```yaml + # kmesh-config.yaml + apiVersion: kmesh.net/v1 + kind: KmeshConfig + metadata: + name: kmesh-config + namespace: kmesh-system + spec: + port: 15007 + logLevel: info + enableMetrics: true + ``` + + b. 释放现有端口: + + ```shell + # 识别并停止冲突进程 + sudo fuser -k 15006/tcp + ``` + +### 依赖管理 + +#### 安装libbpf + +BPF功能所需: + +```bash +# Ubuntu/Debian系统 +sudo apt-get update +sudo apt-get install -y \ + libbpf-dev \ + linux-headers-$(uname -r) + +# 验证安装 +dpkg -l | grep libbpf + +# CentOS/RHEL系统 +sudo yum install -y libbpf-devel kernel-devel +``` + +## 运行时验证 + +### 系统要求检查 + +```shell +# 内核版本检查 +uname -r # 应≥5.10.0以获得完整功能 + +# BPF验证 +sudo bpftool prog list + +# 资源限制 +ulimit -n # 应≥65535 +``` + +### Pod管理 + +验证Kmesh集成: + +```shell +# 检查pod注解 +kubectl get pod -o jsonpath='{.metadata.annotations}' | jq + +# 启用Kmesh管理 +kubectl label namespace default istio.io/dataplane-mode=Kmesh --overwrite + +# 验证Kmesh状态 +kubectl -n kmesh-system get pods -l app=kmesh +``` + +### 日志记录和调试 + +#### 增强日志记录 + +```shell +# 启用调试日志 +kmeshctl accesslog --set default:debug + +# 监控BPF事件(内核≥5.10.0) +kubectl exec -n kmesh-system -- kmesh-daemon log --set bpf:debug + +# 收集所有日志 +kubectl logs -n kmesh-system -l app=kmesh --all-containers --tail=1000 > kmesh-debug.log +``` + +## 清理程序 + +### 清理 + +移除Kmesh及其配置: + +```shell +# 使用Helm +helm uninstall kmesh -n kmesh-system + +# 使用kubectl +kubectl delete namespace kmesh-system +kubectl delete -f kmesh-config.yaml + +# 清理CNI配置 +sudo rm -f /etc/cni/net.d/kmesh-cni* +``` + +### 配置重置 + +重置为默认设置: + +```shell +# 移除命名空间标签 +kubectl label namespace default istio.io/dataplane-mode- + +# 重置CNI +kubectl -n kmesh-system delete pod -l app=kmesh-cni +``` + +## 健康验证 + +### 系统健康检查 + +```shell +# 组件状态 +kubectl get componentstatuses + +# 事件监控 +kubectl get events -n kmesh-system --sort-by='.lastTimestamp' + +# 资源使用情况 +kubectl top pod -n kmesh-system +``` + +## 其他资源 + +- [Kmesh Architecture Guide](/i18n/zh/docusaurus-plugin-content-docs/current/architecture/architecture.md) +- [Performance Tuning](/i18n/zh/docusaurus-plugin-content-docs/current/performance/performance.md) +- [Community Support](/i18n/zh/docusaurus-plugin-content-docs/current/community/contribute.md) + +对于更复杂的问题,请参考我们的[GitHub Issues](https://github.com/kmesh-net/kmesh/issues)或加入我们的社区频道。 + +```text +This translation ensures that: +- The Markdown structure (headers, code blocks, tables) remains intact. +- Descriptive text is translated into natural and accurate Chinese. +- Technical commands and configurations are preserved in their original English form, with comments translated for better understanding. +- The document is ready to be copied and used directly in a Markdown editor. +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/use-enhanced-kernel.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/use-enhanced-kernel.md new file mode 100644 index 00000000..7ab8ec0a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/setup/use-enhanced-kernel.md @@ -0,0 +1,42 @@ +--- +title: 使用增强内核 +sidebar_position: 3 +--- + +# 使用增强内核 + +Kmesh 的某些功能依赖于增强内核(例如,ads 模式下的 L7 流量控制)。要使用它,您可以使用**openEuler 23.03**,它原生支持所有功能。 + +您可以按照以下步骤使用增强内核: + +## 下载 openEuler 23.03 镜像 + +从以下链接下载镜像:https://repo.openeuler.org/openEuler-23.03/ISO/ + +## 安装操作系统 + +这里,我们以 [VMware](https://www.vmware.com/products/workstation-pro/html.html) 为例(您也可以使用其他虚拟机管理工具)。 + +![image](images/install_openEuler.png) + +> **注意:** **openEuler 23.03** 的内核版本是 **6.1.19**。因此您应该选择 **其他 Linux 6.x 内核 64 位** (**Linux 6.x kernel 64bit**)。 + +然后,您可以按照[官方博客](https://www.openeuler.org/zh/blog/20240306vmware/20240306vmware.html)进行安装。 + +## 安装内核头文件 + +Kmesh 根据一些内核头文件(例如 `bpf.h`)来确定是否使用增强内核。因此,您应该通过以下方式安装内核头文件: + +```shell +yum install kernel-headers +``` + +然后,您应该能够在路径 `/usr/include/linux` 中找到内核头文件。 + +## 检查您是否准备好使用增强内核 + +```shell +grep -q "FN(parse_header_msg)" /usr/include/linux/bpf.h && echo "enhanced" || echo "unenhanced" +``` + +现在您可以按照[部署和开发指南](/i18n/zh/docusaurus-plugin-content-docs/current/setup/develop-with-kind.md)来探索 kmesh 的全部功能。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/_category_.json new file mode 100644 index 00000000..d6f69753 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Transport layer", + "position": 4, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/grafana.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/grafana.png new file mode 100644 index 00000000..7fdd698c Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/grafana.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg new file mode 100644 index 00000000..cb09218b Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg new file mode 100644 index 00000000..189abc89 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-graph.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-graph.png new file mode 100644 index 00000000..c64fb45c Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-graph.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-table.png b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-table.png new file mode 100644 index 00000000..0e6e67b2 Binary files /dev/null and b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/images/prometheus-table.png differ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/l4-metrics.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/l4-metrics.md new file mode 100644 index 00000000..b27de692 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/l4-metrics.md @@ -0,0 +1,168 @@ +--- +sidebar_position: 2 +title: 从 Prometheus 查询 L4 指标 +--- + +## 准备工作 + +### 1. 安装 Kmesh + +请参阅[快速入门指南](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md)。 + +> **注意:** 以下内容应添加到 Kmesh 注解中: +> +> ```yaml +> annotations: +> prometheus.io/path: "status/metric" +> prometheus.io/port: "15020" +> prometheus.io/scrape: "true" +> ``` + +### 2. 配置 Kmesh 管理 `default` 命名空间 + +```bash +kubectl label namespace default istio.io/dataplane-mode=Kmesh +``` + +**预期输出:** + +```text +namespace/default labeled +``` + +### 3. 安装 Prometheus 插件 + +Istio 提供了一个基本的示例安装,以快速启动 Prometheus: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +``` + +### 4. 部署 `tcp-echo` 和 `sleep` 应用程序 + +```bash +# 部署 tcp-echo 应用程序 +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/tcp-echo/tcp-echo.yaml + +# 部署 sleep 应用程序 +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/sleep/sleep.yaml + +# 验证部署 +kubectl get po -A +``` + +**预期输出:** + +```bash +NAMESPACE NAME READY STATUS RESTARTS AGE +default sleep-bc9998558-pbfvk 1/1 Running 0 7m +default tcp-echo-7f676db574-mzmql 1/1 Running 0 7m +``` + +> **重要:** 确认 `sleep` 和 `tcp-echo` 确实[由 Kmesh 管理](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md#部署示例应用)。 + +## 从 Prometheus 查询指标 + +### 可用指标 + +Kmesh L4 阶段监控的指标: + +#### 工作负载指标 + +| 名称 | 描述 | +| --------------------------------------------- | --------------------------------------- | +| `kmesh_tcp_workload_connections_opened_total` | 打开到工作负载的 TCP 连接总数 | +| `kmesh_tcp_workload_connections_closed_total` | 关闭到工作负载的 TCP 连接总数 | +| `kmesh_tcp_workload_received_bytes_total` | 通过 TCP 连接响应工作负载接收的总字节数 | +| `kmesh_tcp_workload_sent_bytes_total` | 通过 TCP 连接响应工作负载发送的总字节数 | +| `kmesh_tcp_workload_connections_failed_total` | 失败的到工作负载的 TCP 连接总数 | + +#### 服务指标 + +| 名称 | 描述 | +| ------------------------------------ | ----------------------------------- | +| `kmesh_tcp_connections_opened_total` | 打开到服务的 TCP 连接总数 | +| `kmesh_tcp_connections_closed_total` | 关闭到服务的 TCP 连接总数 | +| `kmesh_tcp_received_bytes_total` | 通过 TCP 连接响应服务接收的总字节数 | +| `kmesh_tcp_sent_bytes_total` | 通过 TCP 连接响应服务发送的总字节数 | +| `kmesh_tcp_connections_failed_total` | 失败的到服务的 TCP 连接总数 | + +### 查询步骤 + +以下是如何通过 Prometheus 查看这些指标: + +#### 1. 验证 Prometheus 服务在集群中运行 + +在 Kubernetes 环境中,执行以下命令: + +```bash +kubectl -n kmesh-system get svc prometheus +``` + +**预期输出:** + +```bash +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +prometheus ClusterIP 10.96.18.252 9090/TCP 24h +``` + +#### 2. 在网格中的应用程序之间建立 TCP 连接 + +使用 `nc` 命令在 `sleep` 和 `tcp-echo` 之间创建 TCP 链接: + +```bash +kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" \ + -c sleep -- sh -c 'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && \ + echo 'connection succeeded' || echo 'connection rejected' +``` + +**预期输出:** + +```text +hello port 9000 +connection succeeded +``` + +#### 3. 打开 Prometheus UI + +使用 port-forward 命令将流量转发到 Prometheus: + +```bash +kubectl port-forward --address 0.0.0.0 svc/prometheus 9090:9090 -n kmesh-system +``` + +**预期输出:** + +```text +Forwarding from 0.0.0.0:9090 -> 9090 +Handling connection for 9090 +Handling connection for 9090 +``` + +#### 4. 执行 Prometheus 查询 + +在网页顶部的 "Expression" 输入框中,输入文本: + +```text +kmesh_tcp_connections_opened_total +``` + +结果将类似于: + +![image](images/prometheus-table.png) + +您还可以通过选择 "Execute" 按钮下方的 "Graph" 选项卡以图形方式查看查询结果。 + +![image](images/prometheus-graph.png) + +## 清理 + +1. 禁用 port-forward。 + +2. 清理 Prometheus: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +``` + +如果您不打算探索任何后续任务,请参阅[快速入门清理](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md#清理)说明以关闭应用程序。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/performace-monitoring.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/performace-monitoring.md new file mode 100644 index 00000000..7ae2540c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/performace-monitoring.md @@ -0,0 +1,53 @@ +--- +sidebar_position: 4 +title: 使用 Grafana 可视化 Kmesh 性能监控 +--- + +## 准备工作 + +1. 使默认命名空间由 Kmesh 管理 +2. 设置相关参数: + - 修改 `bpf/kmesh/probes/performance_probe.h` 文件,将 `#define PERF_MONITOR 0` 更改为 `#define PERF_MONITOR 1`。 + - 在 `deploy/yaml/kmesh.yaml` 中,将 `--enable-perfmonitor=false` 更改为 `--enable-perfmonitor=true`。 +3. 部署 bookinfo 作为示例应用程序,并部署 sleep 作为 curl 客户端 +4. 为默认命名空间安装命名空间粒度的 waypoint + + *以上步骤可参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)* + +5. 部署 Prometheus 和 Grafana: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +## 在网格中的应用程序之间生成一些持续的流量 + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +## 使用 Grafana 可视化 Kmesh 性能监控 + +1. 使用 port-forward 命令将流量转发到 Grafana: + +```bash +kubectl port-forward --address 0.0.0.0 svc/grafana 3000:3000 -n kmesh-system +# Forwarding from 0.0.0.0:3000 -> 3000 +``` + +2. 从浏览器查看仪表板 + + 访问 `Dashboards > Kmesh > Kmesh performance monitoring`: + + ![image](images/kmesh_deamon_monitoring.jpg) + ![image](images/kmesh_map_and_operation_monitoring.jpg) + +## 清理 + +1. 移除 Prometheus 和 Grafana: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/service-metrics.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/service-metrics.md new file mode 100644 index 00000000..6d3f537b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/service-metrics.md @@ -0,0 +1,57 @@ +--- +sidebar_position: 5 +title: 使用 Grafana 可视化服务指标 +--- + +## 准备工作 + +1. 使 `default` 命名空间由 Kmesh 管理 +2. 部署 `bookinfo` 作为示例应用程序,并部署 `sleep` 作为 curl 客户端 +3. 为 `default` 命名空间安装命名空间粒度的 waypoint + + _上述步骤可参考 [安装 Waypoint | Kmesh](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#准备工作)_ + +4. 部署 Prometheus 和 Grafana: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +--- + +## 在网格中的应用程序之间生成一些持续流量 + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +--- + +## 使用 Grafana 可视化服务指标 + +1. 使用 port-forward 命令将流量转发到 Grafana: + +```bash +kubectl port-forward --address 0.0.0.0 svc/grafana 3000:3000 -n kmesh-system +# Forwarding from 0.0.0.0:3000 -> 3000 +``` + +2. 从浏览器查看仪表板 + + 访问 `Dashboards > Kmesh > Kmesh Service Dashboard`: + + ![image](images/grafana.png) + +--- + +## 清理 + +1. 移除 Prometheus 和 Grafana: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +2. 如果您不打算探索任何后续任务,请参阅 [安装 Waypoint/清理](/i18n/zh/docusaurus-plugin-content-docs/current/application-layer/install_waypoint.md#清理) 说明以移除 waypoint 并关闭应用程序。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/tcp-authorization.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/tcp-authorization.md new file mode 100644 index 00000000..4120790f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/tcp-authorization.md @@ -0,0 +1,264 @@ +--- +sidebar_position: 1 +title: TCP 授权 +--- + +本指南将向您展示如何在 Kmesh 中为 TCP 流量设置授权策略。 + +## 开始之前 + +- 了解 [AuthorizationPolicy](#authorizationpolicy) 概念 +- 安装 Kmesh + - 请参阅[快速入门指南](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md) +- 部署示例应用程序并配置它们由 Kmesh 管理 + - 请参阅[部署应用程序](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md#部署示例应用) + - 在 `sleep` 部署中将副本数修改为 2: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sleep +spec: + replicas: 2 + selector: + matchLabels: + app: sleep + template: + metadata: + labels: + app: sleep + spec: + terminationGracePeriodSeconds: 0 + serviceAccountName: sleep + containers: + - name: sleep + image: curlimages/curl + command: ["/bin/sleep", "infinity"] + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /etc/sleep/tls + name: secret-volume + volumes: + - name: secret-volume + secret: + secretName: sleep-secret + optional: true +``` + +- 验证应用程序状态以确保服务应用程序由 Kmesh 管理: + +```bash +# 检查 pod 状态 +kubectl get pod -o wide | grep sleep +``` + +**预期输出:** + +```bash +NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES +sleep-78ff5975c6-phhll 1/1 Running 0 30h 10.244.2.22 ambient-worker +sleep-78ff5975c6-plh7r 1/1 Running 0 30h 10.244.1.46 ambient-worker2 +``` + +```bash +# 验证 Kmesh 管理 +kubectl describe pod httpbin-65975d4c6f-96kgw | grep Annotations +``` + +**预期输出:** + +```text +Annotations: kmesh.net/redirection: enabled +``` + +## 配置 ALLOW 授权策略 + +1. 为 `httpbin` 工作负载创建 "allow-by-srcip" 授权策略: + +```bash +kubectl apply -f - < 此策略仅允许来自指定 IP 地址 `10.244.1.46/32` 的请求,该 IP 地址对应于 pod `sleep-78ff5975c6-plh7r`。 + +2. 验证来自允许 IP 的请求成功: + +```bash +kubectl exec sleep-78ff5975c6-plh7r -- curl http://httpbin:8000/headers +``` + +**预期输出:** + +```json +{ + "headers": { + "Accept": "*/*", + "Host": "httpbin:8000", + "User-Agent": "curl/8.5.0" + } +} +``` + +3. 验证来自其他 IP 的请求被拒绝: + +```bash +kubectl exec sleep-78ff5975c6-phhll -- curl http://httpbin:8000/headers +``` + +**预期输出:** + +```text +curl: (56) Recv failure: Connection reset by peer +``` + +4. 清理 `AuthorizationPolicy`: + +```bash +kubectl delete AuthorizationPolicy allow-by-srcip -n default +``` + +## 配置 DENY 授权策略 + +1. 为 `httpbin` 工作负载创建 "deny-by-srcip" 授权策略: + +```bash +kubectl apply -f - < 此策略拒绝来自指定 IP 地址 `10.244.1.46/32` 的请求,该 IP 地址对应于 pod `sleep-78ff5975c6-plh7r`。 + +2. 验证来自被拒绝 IP 的请求被阻止: + +```bash +kubectl exec sleep-78ff5975c6-plh7r -- curl "http://httpbin:8000/headers" +``` + +**预期输出:** + +```text +curl: (56) Recv failure: Connection reset by peer +``` + +3. 验证来自其他 IP 的请求被允许: + +```bash +kubectl exec sleep-78ff5975c6-phhll -- curl "http://httpbin:8000/headers" +``` + +**预期输出:** + +```json +{ + "headers": { + "Accept": "*/*", + "Host": "httpbin:8000", + "User-Agent": "curl/8.5.0" + } +} +``` + +4. 清理 `AuthorizationPolicy`: + +```bash +kubectl delete AuthorizationPolicy deny-by-srcip -n default +``` + +## 清理 + +请参阅[清理指南](/i18n/zh/docusaurus-plugin-content-docs/current/setup/quick-start.md#清理) + +## AuthorizationPolicy + +### AuthorizationPolicy 字段 + +| 字段 | 类型 | 描述 | 必需 | +|---------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | +| `rules` | `Rule[]` | 可选。用于匹配请求的规则列表。当至少一个规则匹配请求时,匹配发生。如果未设置,则永远不会发生匹配。如果 `action` 为 `ALLOW`,则这等同于为目标工作负载设置默认拒绝。 | 否 | + +### Rule + +`Rule` 匹配来自执行一系列操作的源列表的请求,需满足一系列条件。当至少一个源、一个操作和所有条件匹配请求时,匹配发生。空规则始终匹配。 + +| 字段 | 类型 | 描述 | 必需 | +|--------|----------|---------------------------------------------------------------------------------------| -------- | +| `from` | `From[]` | 可选。`from` 指定请求的源。如果未设置,则允许任何源。| 否 | +| `to` | `To[]` | 可选。`to` 指定请求的操作。如果未设置,则允许任何操作。 | 否 | + +#### Rule.From + +`From` 包含源列表。 + +| 字段 | 类型 | 描述 | 必需 | +|----------|----------|-------------------------------------------| -------- | +| `source` | `Source` | `Source` 指定请求的源。 | 否 | + +#### Rule.To + +`To` 包含操作列表。 + +| 字段 | 类型 | 描述 | 必需 | +|-------------|-------------|-------------------------------------------------| -------- | +| `operation` | `Operation` | `Operation` 指定请求的操作。 | 否 | + +### Source + +`Source` 指定请求的源身份。源中的字段是 AND 关系。 + +例如,以下源匹配如果 `principal` 是 `admin` 或 `dev` 并且 `namespace` 是 `prod` 或 `test` 并且 `ip` 不是 `203.0.113.4`: + +```yaml +principals: ["admin", "dev"] +namespaces: ["prod", "test"] +notIpBlocks: ["203.0.113.4"] +``` + +| 字段 | 类型 | 描述 | 必需 | +|-----------------|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | +| `principals` | `string[]` | 可选。从对等证书派生的对等身份列表。对等身份的格式为 `"/ns//sa/"`,例如 `"cluster.local/ns/default/sa/productpage"`。此字段需要启用 mTLS,并且与 `source.principal` 属性相同。如果未设置,则允许任何 `principal`。 | 否 | +| `notPrincipals` | `string[]` | 可选。对等身份的负匹配列表。 | 否 | +| `namespaces` | `string[]` | 可选。从对等证书派生的命名空间列表。此字段需要启用 mTLS,并且与 `source.namespace` 属性相同。如果未设置,则允许任何命名空间。 | 否 | +| `notNamespaces` | `string[]` | 可选。命名空间的负匹配列表。 | 否 | +| `ipBlocks` | `string[]` | 可选。IP 块列表,从 IP 数据包的源地址填充。支持单个 IP(例如 `203.0.113.4`)和 CIDR(例如 `203.0.113.0/24`)。这与 `source.ip` 属性相同。如果未设置,则允许任何 IP。 | 否 | +| `notIpBlocks` | `string[]` | 可选。IP 块的负匹配列表。 | 否 | + +### Operation + +`Operation` 指定请求的操作。操作中的字段是 AND 关系。 + +| 字段 | 类型 | 描述 | 必需 | +|------------|------------|-------------------------------------------------------------------------------------------| -------- | +| `ports` | `string[]` | 可选。连接中指定的端口列表。如果未设置,则允许任何端口。| 否 | +| `notPorts` | `string[]` | 可选。连接中指定的端口的负匹配列表。 | 否 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/xdp-auth.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/xdp-auth.md new file mode 100644 index 00000000..cb4607e4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/transpot-layer/xdp-auth.md @@ -0,0 +1,212 @@ +--- +sidebar_position: 3 +title: XDP 中的 TCP 授权 +--- + +## XDP 中的授权 + +之前,我们推出了[用户空间授权功能](/i18n/zh/docusaurus-plugin-content-docs/current/transpot-layer/tcp-authorization.md),其中授权结果在用户空间进行验证。本文档解释了如何直接在 XDP 程序中启用授权。目前,基于 XDP 的授权仅支持基于端口和 IP 地址的验证。 + +### 如何启用基于 XDP 的授权 + +我们可以使用 `kmeshctl` 来启用基于 XDP 的授权: + +```bash +./kmeshctl authz enable +``` + +修改 BPF 日志级别: + +```bash +./kmeshctl log <$kmeshnode1> --set bpf:debug +``` + +## 配置拒绝授权策略 + +### 配置目标端口拒绝授权策略 + +为 Fortio 工作负载创建一个“deny-by-dstport”授权策略,拒绝发送到指定端口地址的请求。在此示例中,发送到端口 8080 的流量被拒绝: + +```yaml +# deny-by-dstport.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: deny-by-dstport +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - to: + - operation: + ports: + - "8080" +``` + +应用策略: + +```bash +kubectl apply -f deny-by-dstport.yaml +``` + +#### 测试策略 + +Fortio 流量返回的状态码确认发送到端口 8080 的流量已被拒绝: + +```bash +kubectl exec -it fortio-client-deployment-6966bf9488-tpwpj -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.7:8080 +``` + +预期输出: + +```text +... +IP addresses distribution: +10.244.0.7:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3005.022 ms avg, 0.3 qps +``` + +Kmesh 记录的日志中也会打印特定信息: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +预期输出: + +```log +... +time="2024-12-25T15:23:12+08:00" level=info msg="[AUTH] DEBUG: port 8080 in destination_ports, matched" subsys=ebpf +time="2024-12-25T15:23:12+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +``` + +### 配置源 IP 拒绝授权策略 + +创建策略以拒绝来自特定源 IP 的流量: + +```yaml +# deny-by-srcip.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: allow-by-srcip1 + namespace: default +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - from: + - source: + ipBlocks: + - 10.244.1.36 +``` + +应用策略: + +```bash +kubectl apply -f deny-by-srcip.yaml +``` + +#### 测试策略 + +Fortio 流量返回的状态码确认从 IP 10.244.1.36 发送的流量已被拒绝: + +```bash +# fortio-client-deployment-6966bf9488-m96qp 的 IP 地址是 10.244.1.36 +kubectl exec -it fortio-client-deployment-6966bf9488-m96qp -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.36:8080 +``` + +预期输出: + +```text +... +IP addresses distribution: +10.244.0.36:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3005.563 ms avg, 0.3 qps +``` + +Kmesh 记录的日志中也会打印特定信息: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +预期输出: + +```log +... +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +time="2024-12-26T15:06:14+08:00" level=info msg="[AUTH] DEBUG: no ports configured, matching by default" subsys=ebpf +time="2024-12-26T15:06:14+08:00" level=info msg="[AUTH] DEBUG: IPv4 match srcip: Rule IP: af40124, Prefix Length: 32, Target IP: af40124\n" subsys=ebpf +``` + +### 配置目标 IP 拒绝授权策略 + +创建策略以拒绝发送到特定目标 IP 的流量: + +```yaml +# deny-by-dstip.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: deny-dstip +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - when: + - key: destination.ip + values: ["10.244.0.36"] +``` + +应用策略: + +```bash +kubectl apply -f deny-by-dstip.yaml +``` + +#### 测试策略 + +Fortio 流量返回的状态码确认发送到 IP 10.244.0.36 的流量已被拒绝: + +```bash +kubectl exec -it fortio-client-deployment-6966bf9488-m96qp -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.36:8080 +``` + +预期输出: + +```text +... +10.244.0.36:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3004.974 ms avg, 0.3 qps +``` + +Kmesh 记录的日志中也会打印特定信息: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +预期输出: + +```log +... +time="2024-12-26T15:05:22+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: no ports configured, matching by default" subsys=ebpf +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: IPv4 match dstip: Rule IP: af40024, Prefix Length: 32, Target IP: af40024\n" subsys=ebpf +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/welcome.md b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/welcome.md new file mode 100644 index 00000000..4dcd1952 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/version-1.2.0/welcome.md @@ -0,0 +1,32 @@ +--- +sidebar_position: 1 +title: Welcome +last_update: + date: "2025-02-22" +--- + +# 欢迎来到 Kmesh:高性能、低开销的服务网格数据面 + +Kmesh 利用 eBPF 和可编程内核将服务治理下沉到操作系统,实现网格内服务访问路径从多跳变为一跳,从而大幅提升服务网格的性能。与传统服务网格相比,它提供了低延迟、无需 sidecar 和低资源消耗等优势。 + +## 为什么选择 Kmesh? + +- **卓越的性能**:通过内核级优化降低服务网格的延迟 +- **资源高效**:通过在操作系统层实现服务治理,最小化开销 +- **简化运维**:通过内核集成的流量路由,简化服务网格管理 +- **云原生集成**:与现有的云原生基础设施无缝协作 + +## 核心优势 + +| 优势 | 描述 | +| -------- | --------------------------------------- | +| 延迟降低 | 直接内核路径路由减少服务间通信开销 | +| 资源优化 | 通过操作系统层实现,降低 CPU 和内存使用 | +| 架构简化 | 服务访问路径中更少的跳数,提升整体性能 | + +在以下文档中,我们将介绍: + +- [架构](architecture/architecture.md) 和 Kmesh 的优势亮点。 +- Kmesh 的[快速入门](setup/quick-start.md)。 +- Kmesh 的[性能](performance/)。 +- Kmesh 的[社区](community/contribute.md)。 diff --git a/versioned_docs/version-1.2.0/application-layer/_category_.json b/versioned_docs/version-1.2.0/application-layer/_category_.json new file mode 100644 index 00000000..e2eeff73 --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Application Layer", + "position": 6, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/application-layer/circuit-breaker.md b/versioned_docs/version-1.2.0/application-layer/circuit-breaker.md new file mode 100644 index 00000000..28a03401 --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/circuit-breaker.md @@ -0,0 +1,152 @@ +--- +title: Circuit Breaker +sidebar_position: 10 +--- + +This document provides a step-by-step guide on how to test the circuit breaking functionality of kmesh. It covers deploying the necessary components, configuring traffic rules, and observing the circuit breaking behavior. + +## Step 1. Deploy kmesh + +Please read [Quick Start](https://kmesh.net/docs/setup/quick-start) to complete the deployment of kmesh. + +## Step 2. Deploy fortio and httpbin + +``` sh +kubectl apply -f -< /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +Next, create a dedicated Waypoint proxy for the `httpbin` service and label the service to direct its traffic through this Waypoint. + +```sh +kmeshctl waypoint apply -n default --name httpbin-waypoint --image ghcr.io/kmesh-net/waypoint:latest +kubectl label service httpbin istio.io/use-waypoint=httpbin-waypoint +``` + +## Step 4. Configure DestinationRule + +```sh +kubectl apply -f - <.*" + Simple Bookstore App + ``` + +## Install waypoint + +Waypoints can be used at three granularity: namespace, service and pod. And you could also install multiple waypoints at different granularity within a namespace. +Below we will learn how to deploy different waypoints for different granularity. We can use `kmeshctl waypoint` subcommands to generate or apply waypoint. + +To enable a namespace, service or pod to use a waypoint, add the `istio.io/use-waypoint` label with a value of the waypoint name. +We can also specify a customized waypoint image with `--image`, by default this default to `ghcr.io/kmesh-net/waypoint:{VERSION}` + +### Configure a waypoint for a specific service + +Deploy a waypoint `reviews-svc-waypoint` for service `reviews`, so any traffic to `reviews` from a client managed by Kmesh will be mediated by the waypoint proxy + +```bash +[root@ ~]# kmeshctl waypoint apply --for service -n default --name=reviews-svc-waypoint + +waypoint default/reviews-svc-waypoint applied +``` + +Label the `reviews` service to use `reviews-svc-waypoint` waypoint: + +```bash +[root@ ~]# $ kubectl label service reviews istio.io/use-waypoint=reviews-svc-waypoint + +service/reviews labeled +``` + +After the waypoint is up and running, Kmesh L7 is enabled! + +```bash +[root@ ~]# kubectl get pods +NAME READY STATUS RESTARTS AGE +details-v1-cdd874bc9-xcdnj 1/1 Running 0 30m +productpage-v1-5bb9985d4d-z8cws 1/1 Running 0 30m +ratings-v1-6484d64bbc-pkv6h 1/1 Running 0 30m +reviews-svc-waypoint-8cb4bdbf-9d5mj 1/1 Running 0 30m +reviews-v1-598f9b58fc-2rw7r 1/1 Running 0 30m +reviews-v2-5979c6fc9c-72bst 1/1 Running 0 30m +reviews-v3-7bbb5b9cf7-952d8 1/1 Running 0 30m +sleep-5577c64d7c-n7rxp 1/1 Running 0 30m +``` + +### Configure waypoint for a specific namespace + +Deploy a waypoint for the `default` namespace with default name `waypoint`. By specifying `--enroll-namespace`, the namespace will be labeled with `istio.io/use-waypoint=waypoint` + +```bash +[root@ ~]# kmeshctl waypoint apply -n default --enroll-namespace +waypoint default/waypoint applied +namespace default labels with "istio.io/use-waypoint: waypoint" +``` + +### Configure waypoint for a specific pod + +Deploy a waypoint called reviews-v2-pod-waypoint for the `reviews-v2-5979c6fc9c-72bst` pod. + +```bash +[root@ ~]# kmeshctl waypoint apply -n default --name reviews-v2-pod-waypoint --for workload +waypoint default/reviews-v2-pod-waypoint applied +# Label the `reviews-v2` pod to use `reviews-v2-pod-waypoint` waypoint. +[root@ ~]# kubectl label pod reviews-v2-5979c6fc9c-72bst istio.io/use-waypoint=reviews-v2-pod-waypoint +pod/reviews-v2-5b667bcbf8-spnnh labeled +``` + +Now any requests from pods in the Kmesh to the `reviews-v2` pod IP will be routed through `reviews-v2-pod-waypoint` waypoint for L7 processing and policy enforcement. + +## Cleanup + +If you are **not** planning to explore any follow-on tasks, go on with the cleanup steps + +1. Remove waypoint: + + ### Remove waypoint for service + + ```bash + [root@ ~]# kmeshctl waypoint delete reviews-svc-waypoint + [root@ ~]# kubectl label service reviews istio.io/use-waypoint- + ``` + + ### Remove waypoint for namespace + + ```bash + [root@ ~]# kmeshctl waypoint delete waypoint + [root@ ~]# kubectl label namespace default istio.io/use-waypoint- + ``` + + ### Remove waypoint for pod + + ```bash + [root@ ~]# kmeshctl waypoint delete reviews-v2-pod-waypoint + [root@ ~]# kubectl label pod -l version=v2,app=reviews istio.io/use-waypoint- + ``` + +2. Remove sample applications: + + ```bash + [root@ ~]# kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/bookinfo/platform/kube/bookinfo.yaml + [root@ ~]# kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.21/samples/sleep/sleep.yaml + ``` + +3. Remove default namespace from Kmesh: + + ```bash + [root@ ~]# kubectl label namespace default istio.io/dataplane-mode- + ``` + +## Demo + +
+ +
diff --git a/versioned_docs/version-1.2.0/application-layer/kiali.md b/versioned_docs/version-1.2.0/application-layer/kiali.md new file mode 100644 index 00000000..540f27b7 --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/kiali.md @@ -0,0 +1,62 @@ +--- +sidebar_position: 8 +title: Use Kiali to visualize traffic graph under Kmesh +--- + +## Preparation + +1. Make default namespace managed by Kmesh. + +2. Deploy bookinfo as sample application and sleep as curl client. + +3. \[optional\] Install service granularity waypoint for service `reviews`. + + _The above steps could refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation). When installing Istio, we recommend installing Istio ambient mode instead of only installing Istiod, because Kiali currently depends on Istio components to work._ + +4. Deploy prometheus that record Kmesh metrics as Istio standard metrics. + + _This Prometheus addon leverages the Prometheus recording rules and relabeling configurations to convert Kmesh L4 metrics into Istio standard metrics, so that Kiali could visualize these metrics._ + + ```bash + kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus_recording_istio.yaml + ``` + +5. Deploy Kiali which reads metrics from the Prometheus. + + ```bash + kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/kiali.yaml + ``` + +## Generate some continuous traffic between applications in the mesh + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +## Use Kiali to visualize the traffic graph of services + +1. Use the port-forward command to forward traffic to kiali. + + ```bash + kubectl port-forward --address 0.0.0.0 svc/kiali 20001:20001 -n kmesh-system + Forwarding from 0.0.0.0:20001 -> 20001 + ``` + +2. View the traffic graph in Kiali from browser. + + Visit `Traffic Graph` panel. Select the `default` namespace at the top of left. + + ![image](images/kiali.png) + + _In this traffic topology graph, the blue lines represent TCP traffic, which is proxied by Kmesh, while the green lines represent HTTP traffic, which is proxied by Waypoint. For more information about Kiali's traffic topology graph, please refer to [Kiali's documentation](https://kiali.io/docs/features/topology/)._ + +## Cleanup + +1. Remove prometheus and grafana: + + ```bash + kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus_recording_istio.yaml + kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/kiali.yaml + ``` + +2. If you are not planning to explore any follow-on tasks, refer to the [Install Waypoint/Cleanup](/docs/application-layer/install_waypoint.md#cleanup) instructions to remove waypoint and shutdown the application. diff --git a/versioned_docs/version-1.2.0/application-layer/locality-loadbalance.md b/versioned_docs/version-1.2.0/application-layer/locality-loadbalance.md new file mode 100644 index 00000000..e4deacdf --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/locality-loadbalance.md @@ -0,0 +1,373 @@ +--- +sidebar_position: 9 +title: Locality Load Balancing +--- + +This document explains how to use Locality Load Balancing with Istio in Kmesh. + +Note: Kmesh's current Locality Load Balancing operates at L4 and only supports [Locality Failover](https://istio.io/latest/docs/tasks/traffic-management/locality-load-balancing/failover/). + +## What is Locality Load Balancing? + +A locality describes the geographic location of a workload instance in the mesh. Locality Load Balancing improves availability and performance by routing traffic based on the location of service instances. + +We strongly recommend reading https://istio.io/latest/docs/tasks/traffic-management/locality-load-balancing/ for background on locality load balancing. + +## Supported Modes and Configuration Methods for Kmesh + +Currently, Istio's ambient mode supports specifying a fixed locality load-balancing policy via configuration. Kmesh supports two modes: PreferClose and Local. + +### 1. PreferClose + +Failover mode that uses NETWORK, REGION, ZONE, and SUBZONE as the routing preference. + +- With `spec.trafficDistribution` (k8s >= beta [1.31.0](https://kubernetes.io/docs/concepts/services-networking/service/), istio >= [1.23.1](https://istio.io/latest/news/releases/1.23.x/announcing-1.23/)) + + ```yaml + spec: + trafficDistribution: # spec.trafficDistribution + preferClose: true + ``` + +- With annotation + + ```yaml + metadata: + annotations: + networking.istio.io/traffic-distribution: PreferClose + ``` + +### 2. Local + +Strict mode that restricts traffic to the current node. + +- Set `spec.internalTrafficPolicy: Local` (k8s >= beta 1.24 or >= 1.26) + + ```yaml + spec: + internalTrafficPolicy: Local + ``` + +## Experimental Testing + +### Prepare the environment + +- Refer to [develop with kind](/docs/setup/develop-with-kind.md). +- A three-node kind cluster is required. +- istio >= 1.23.1 +- k8s >= 1.31.0 +- Ensure sidecar injection is disabled: `kubectl label namespace default istio-injection-` +- Required images: + - `docker.io/istio/examples-helloworld-v1` + - `curlimages/curl` + +```yaml +kind create cluster --image=kindest/node:v1.31.0 --config=- < /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v1.4.0" | kubectl create -f -; } +``` + +Next, create a dedicated Waypoint proxy for the `httpbin` service and label the service to direct its traffic through this Waypoint. + +```sh +kmeshctl waypoint apply -n default --name httpbin-waypoint --image ghcr.io/kmesh-net/waypoint:latest + +kubectl label service httpbin istio.io/use-waypoint=httpbin-waypoint +``` + +### 4. Deploy envoyFilter + +This `EnvoyFilter` resource injects a local rate-limit filter into the `httpbin` service's Waypoint proxy. The filter is configured with the following rules: + +- A request with the header `quota: low` will be limited to **1 request per 300 seconds**. +- A request with the header `quota: medium` will be limited to **3 requests per 300 seconds**. +- Other requests will be subject to a default limit of **10 requests per 300 seconds**. + +The `workloadSelector` ensures that this filter is applied only to the `httpbin-waypoint` proxy. + +```sh +kubectl apply -f -< + + diff --git a/versioned_docs/version-1.2.0/application-layer/try-request-routing.md b/versioned_docs/version-1.2.0/application-layer/try-request-routing.md new file mode 100644 index 00000000..9bba610a --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/try-request-routing.md @@ -0,0 +1,167 @@ +--- +sidebar_position: 4 +title: Try Request Routing +--- + +## Preparation + +1. Make default namespace managed by Kmesh +2. Deploy bookinfo as sample application and sleep as curl client +3. Install service granularity waypoint for reviews service + + _The above steps could refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation)_ + +## Apply version-based routing + +1. Run the following command to create the route rules: + +```bash +kubectl apply -f -<reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r + ... + reviews-v1-598f9b58fc-jc25r + reviews-v1-598f9b58fc-jc25r +``` + +## Apply user-identity-based routing + +Next, you will change the route configuration so that all traffic from a specific user is routed to a specific service version. In this case, all traffic from a user named Jason will be routed to the service `reviews:v2`. + +This example is enabled by the fact that the `productpage` service adds a custom `end-user` header to all outbound HTTP requests to the reviews service. + +1. Run the following command to enable user-based routing: + +```bash +kubectl apply -f -< + + diff --git a/versioned_docs/version-1.2.0/application-layer/try-request-timeout.md b/versioned_docs/version-1.2.0/application-layer/try-request-timeout.md new file mode 100644 index 00000000..66ab7d0f --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/try-request-timeout.md @@ -0,0 +1,130 @@ +--- +sidebar_position: 7 +title: Try Request Timeouts +--- + +# Try Request Timeouts + +## Preparation + +1. Make default namespace managed by Kmesh + +2. Deploy bookinfo as sample application + +3. Install service granularity waypoint for reviews service + + _The above steps could refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation)_ + +4. And install waypoint for ratings service + + ```bash + istioctl x waypoint apply -n default --name ratings-svc-waypoint + kubectl label service ratings istio.io/use-waypoint=ratings-svc-waypoint + kubectl annotate gateway ratings-svc-waypoint sidecar.istio.io/proxyImage=ghcr.io/kmesh-net/waypoint:latest + ``` + +## Request timeouts + +A timeout for HTTP requests can be specified using a timeout field in a route rule. By default, the request timeout is disabled, but in this task you override the `reviews` service timeout to half a second. To see its effect, however, you also introduce an artificial 2 second delay in calls to the `ratings` service. + +1. Route requests to v2 of the `reviews` service, i.e., a version that calls the `ratings` service: + + ```bash + kubectl apply -f - < + + diff --git a/versioned_docs/version-1.2.0/application-layer/try-service-entry.md b/versioned_docs/version-1.2.0/application-layer/try-service-entry.md new file mode 100644 index 00000000..40017c3a --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/try-service-entry.md @@ -0,0 +1,466 @@ +--- +sidebar_position: 5 +title: Try Service Entry +--- + +Service Entry enables you to extend Istio's service registry by adding entries for external services. This allows applications in the mesh to discover, access, and apply traffic policies to services that are not automatically discovered in the service mesh. With Kmesh's DNS Controller for Workloads, Service Entry now supports dynamic DNS resolution, making it seamless to integrate external services with changing IP addresses. + +## What is Service Entry? + +Service Entry is a critical Istio resource that allows you to: + +- **Add external services** to the mesh's internal service registry +- **Enable traffic management** (routing, load balancing, retries) for external services +- **Support multiple resolution modes** including DNS, STATIC, and NONE +- **Control egress traffic** with consistent policies + +Kmesh enhances Service Entry with intelligent DNS resolution that automatically handles hostname-to-IP address mapping for external services, ensuring seamless connectivity even when backend addresses change dynamically. + +## Preparation + +Before getting started, ensure you have completed the following steps: + +1. **Make default namespace managed by Kmesh** +2. **Deploy Httpbin as sample application and Sleep as curl client** +3. **Install waypoint for default namespace** + + _For detailed instructions on the above steps, refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation)_ + +## Verify Environment Setup + +Confirm that the httpbin and sleep applications are running properly: + +```bash +kubectl get pods +``` + +You should see both services in Running state: + +```bash +NAME READY STATUS RESTARTS AGE +httpbin-6f4464f6c5-h9x2p 1/1 Running 0 30s +sleep-9454cc476-86vgb 1/1 Running 0 5m +``` + +## Understanding Service Entry Configuration + +### Basic Service Entry with DNS Resolution + +Let's create a Service Entry that defines a virtual external service. This example demonstrates how Kmesh's DNS Controller automatically resolves the backend hostname: + +```bash +kubectl apply -f - </dev/null || true +kubectl delete serviceentry multi-endpoint-svc -n default 2>/dev/null || true +``` + +If you're not planning to continue with subsequent experiments, refer to the [Install Waypoint/Cleanup](/docs/application-layer/install_waypoint.md#cleanup) section for instructions on removing the waypoint and cleaning up applications. + +## Summary + +Through this guide, you learned how to: + +1. **Add external services** to the Istio service mesh using Service Entry +2. **Configure DNS-based resolution** leveraging Kmesh's intelligent DNS Controller +3. **Use static IP endpoints** for services with fixed addresses +4. **Set up multiple backends** with automatic load balancing +5. **Access real external services** on the internet from within the mesh +6. **Troubleshoot common issues** related to Service Entry configuration + +### Key Takeaways + +- **Service Entry extends your mesh** beyond automatically discovered services +- **Kmesh's DNS Controller** provides dynamic, automatic hostname resolution +- **Multiple resolution modes** (DNS, STATIC, NONE) support different use cases +- **DNS resolution is asynchronous** and includes retry logic for reliability +- **Service Entry works seamlessly** with other Istio features like traffic routing and policies + +Service Entry is an essential tool for managing external service dependencies in Istio, providing consistent visibility, control, and reliability for services outside your mesh. diff --git a/versioned_docs/version-1.2.0/application-layer/try-traffic-shifting.md b/versioned_docs/version-1.2.0/application-layer/try-traffic-shifting.md new file mode 100644 index 00000000..f14956a8 --- /dev/null +++ b/versioned_docs/version-1.2.0/application-layer/try-traffic-shifting.md @@ -0,0 +1,102 @@ +--- +sidebar_position: 5 +title: Try Traffic Shifting +--- + +## Preparation + +1. Make default namespace managed by Kmesh +2. Deploy bookinfo as sample application and sleep as curl client +3. Install service granularity waypoint for reviews service + +_The above steps could refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation)_ + +## Apply weight-based routing + +Configure traffic routing to send 90% of requests to `reviews v1` and 10% to `reviews v2`: + +```bash +[root@ ~]# kubectl apply -f -<reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + ... + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 + reviews-v1-57c85f47fb-n9llm + reviews-v1-57c85f47fb-n9llm + reviews-v2-64776cb9bd-grnd2 +``` + +## Understanding what happened + +Because `default` namespace has been managed by Kmesh and we have deployed a waypoint proxy for service `bookinfo-reviews`, so all traffic sent to service `reviews` will be forwarded to waypoint by Kmesh. Waypoint will send 90% of requests to `reviews v1` and 10% to `reviews v2` according to the route rules we set. + +## Cleanup + +1. Remove the application routing rules: + +```bash +kubectl delete virtualservice reviews +kubectl delete destinationrules reviews +``` + +2. If you are not planning to explore any follow-on tasks, refer to the [Install Waypoint/Cleanup](/docs/application-layer/install_waypoint.md#cleanup) instructions to remove waypoint and shutdown the application. + +## Demo + +
+ +
diff --git a/versioned_docs/version-1.2.0/architecture/_category_.json b/versioned_docs/version-1.2.0/architecture/_category_.json new file mode 100644 index 00000000..7d9d2cf5 --- /dev/null +++ b/versioned_docs/version-1.2.0/architecture/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Architecture", + "position": 3, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/architecture/architecture.md b/versioned_docs/version-1.2.0/architecture/architecture.md new file mode 100644 index 00000000..694d0e1a --- /dev/null +++ b/versioned_docs/version-1.2.0/architecture/architecture.md @@ -0,0 +1,40 @@ +--- +title: Kmesh Architecture +description: "" +sidebar_position: 1 +--- + +![image](images/kmesh-arch.png) + +## Architecture Overview + +The software architecture of Kmesh consists of the following core components: + +| Component | Description | +| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- | +| Kmesh-daemon | The daemon responsible for eBPF Orchestration lifecycle management, xDS protocol integration, observability, and other functions | +| eBPF Orchestration | The traffic orchestration implemented with eBPF, including dynamic routing, authorization, load balancing | +| Waypoint | Based on istio's waypoint to adapt to Kmesh protocols, responsible for L7 traffic management | + +## Component Details + +### Kmesh-daemon + +- eBPF lifecycle management +- xDS protocol integration +- Observability and monitoring +- Configuration management + +### eBPF Orchestration + +- Dynamic routing implementation +- Authorization +- Load balancing optimization +- Traffic acceleration + +### Waypoint + +- L7 traffic management +- Protocol adaptation for Kmesh +- Service mesh integration +- Traffic policy enforcement diff --git a/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.png b/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.png new file mode 100644 index 00000000..8acbdaea Binary files /dev/null and b/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.png differ diff --git a/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.svg b/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.svg new file mode 100644 index 00000000..0dcd6925 --- /dev/null +++ b/versioned_docs/version-1.2.0/architecture/images/kmesh-arch.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/architecture/roadmap.md b/versioned_docs/version-1.2.0/architecture/roadmap.md new file mode 100644 index 00000000..7b937887 --- /dev/null +++ b/versioned_docs/version-1.2.0/architecture/roadmap.md @@ -0,0 +1,31 @@ +--- +title: Roadmap +description: "" +sidebar_position: 2 +--- + +| Feature Domain | Feature | 2023.H1 | 2023.H2 | 2024.H1 | 2024.H2 | +| --------------------------------- | -------------------------------------- | :-----: | :-----: | :-----: | :-----: | +| **Traffic Management** | Sidecarless mesh | ✓ | | | | +| | Sockmap | | ✓ | | | +| | Programmable governance based on eBPF | ✓ | | | | +| | HTTP1.1 protocol | ✓ | | | | +| | HTTP2 protocol | | | | ✓ | +| | gRPC protocol | | | | ✓ | +| | QUIC protocol | | | | ✓ | +| | TCP protocol | | ✓ | | | +| | Retry | | | ✓ | | +| | Routing | ✓ | | | | +| | Load balancing | ✓ | | | | +| | Fault injection | | | | ✓ | +| | Gray release | ✓ | | | | +| | Circuit Breaker | | | ✓ | | +| | Rate Limits | | | ✓ | | +| **Service Security** | SSL-based two-way authentication | | | | ✓ | +| | L7 authorization | | | | ✓ | +| | Cgroup-level isolation | ✓ | | | | +| **Traffic Monitoring** | Governance indicator monitoring | | ✓ | | | +| | End-to-end observability | | | | ✓ | +| **Programmable** | Plug-in expansion capability | | | | ✓ | +| **Ecosystem Collaboration** | Data plane collaboration (Envoy, etc.) | | ✓ | | | +| **Operating Environment Support** | Container | ✓ | | | | diff --git a/versioned_docs/version-1.2.0/community/_category_.json b/versioned_docs/version-1.2.0/community/_category_.json new file mode 100644 index 00000000..0be74b38 --- /dev/null +++ b/versioned_docs/version-1.2.0/community/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Community", + "position": 8, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/community/contribute.md b/versioned_docs/version-1.2.0/community/contribute.md new file mode 100644 index 00000000..34cd548a --- /dev/null +++ b/versioned_docs/version-1.2.0/community/contribute.md @@ -0,0 +1,34 @@ +--- +title: Contributing +sidebar_position: 1 +--- + +## Code of Conduct + +Kmesh follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md). + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [kmesh.net.dev@gmail.com](mailto:kmesh.net.dev@gmail.com). + +## Community Expectations + +Kmesh is a community project driven by its community which strives to promote a healthy, friendly and productive environment. +The community's goal is to build a high-performance service governance framework that requires the support of communities with similar aspirations. + +- See [Community Membership](membership.md) for a list of various community roles. With gradual contributions, one can move up in the chain. + +## Preparation + +- Fork the repository on GitHub +- Download the repository +- Read [CONTRIBUTING](https://github.com/kmesh-net/kmesh/blob/main/CONTRIBUTING.md) for more details + +## Meeting Information + +We host regular community meetings where contributors, maintainers, and users can share updates, discuss ideas, and collaborate on ongoing work. + +- **Frequency:** Every 2 weeks on **Thursday** +- **Time:** 16:00 China / 08:00 UTC / 13:30 India Standard Time [Convert to your timezone](https://dateful.com/time-zone-converter?t=14%3A30&tz=GMT%2B8&) +- **Meeting Link:** [Joining Link](https://zoom-lfx.platform.linuxfoundation.org/meeting/99299011908?password=f4c31ddd-11ed-42ae-a617-3e0842c39c58) +- **Meeting Notes & Agenda:** [Google Docs](https://docs.google.com/document/d/1fFqolwWMVMk92yXPHvWGrMgsrb8Xru_v4Cve5ummjbk/edit?tab=t.0#heading=h.o8pz6aqnzzgk) + +Everyone is welcome to join — whether you are an active contributor, an interested user, or someone evaluating Kmesh for your needs. diff --git a/versioned_docs/version-1.2.0/community/feature-lifecycle.md b/versioned_docs/version-1.2.0/community/feature-lifecycle.md new file mode 100644 index 00000000..c172b04d --- /dev/null +++ b/versioned_docs/version-1.2.0/community/feature-lifecycle.md @@ -0,0 +1,82 @@ +--- +title: Feature Lifecycle +sidebar_position: 2 +--- + +This document is to clarify definitions and differences between features and corresponding APIs +during different development stages (versions). + +Each version has different level of stability, support time, +and requires different graduation criteria moving to next level: + +- [Alpha](#alpha) +- [Beta](#beta) +- [GA](#ga) + +## Alpha + +The feature may be changed/upgraded in incompatible ways in the later versions. + +The source code will be available in the release branch/tag as well as in the binaries. + +Support for the feature can be stopped any time without notice. + +The feature may have bugs. + +The feature may also induce bugs in other APIs/Features if enabled. + +The feature may not be completely implemented. + +The API version names will be like v1alpha1, v1alpha2, etc. The suffixed number will be incremented by 1 in each upgrade. + +### Graduation Criteria + +- Each feature will start at alpha level. +- Should not break the functioning of other APIs/Features. + +## Beta + +The feature may not be changed/upgraded in incompatible ways in later versions, +but if changed in incompatible ways then upgrade strategy will be provided. + +The source code will be available in the release branch/tag as well as in the binaries. + +Support for the feature will not be stopped without 2 minor releases notice and will be present in at least next 2 minor releases. + +The feature will have few bugs. + +The feature will not induce bugs in other APIs/Features if enabled. + +The feature will be completely implemented. + +The API version names will be like v1beta1, v1beta2, etc. The suffixed number will be incremented by 1 in each upgrade. + +### Graduation Criteria + +- Should have at least 50% coverage in e2e tests. +- Project agrees to support this feature for at least next 2 minor releases and notice of at least 2 minor releases will be given before stopping the support. +- Feature Owner should commit to ensure backward/forward compatibility in the later versions. + +## GA + +The feature will not be changed/upgraded in incompatible ways in the next couple of versions. + +The source code will be available in the release branch/tag as well as in the binaries. + +Support for the feature will not be stopped without 4 minor releases notice and will be present in at least next 4 minor releases. + +The feature will not have major bugs as it will be tested completely as well as have e2e tests. + +The feature will not induce bugs in other APIs/Features if enabled. + +The feature will be completely implemented. + +The API version names will be like v1, v2, etc. + +### Graduation Criteria + +- Should have complete e2e tests. +- Code is thoroughly tested and is reported to be very stable. +- Project will support this feature for at least next 4 minor releases and notice of at least 4 minor releases will be given before stopping support. +- Feature Owner should commit to ensure backward/forward compatibility in the later versions. +- Consensus from Kmesh Maintainers as well as Feature/API Owners who use/interact with the Feature/API. diff --git a/versioned_docs/version-1.2.0/community/governance.md b/versioned_docs/version-1.2.0/community/governance.md new file mode 100644 index 00000000..b9cda686 --- /dev/null +++ b/versioned_docs/version-1.2.0/community/governance.md @@ -0,0 +1,89 @@ +--- +title: Governance +sidebar_position: 3 +--- + +# Kmesh Project Governance + +Kmesh is a high-performance and low overhead service mesh data plane based on eBPF and programmable kernel. +This governance explains how the project is run. + +- Kmesh Project Governance + - [Values](#values) + - [Membership](#membership) + - [Meetings](#meetings) + - [Code of Conduct](#code-of-conduct) + - [Security Response Team](#security-response-team) + - [Voting](#voting) + - [Modifying this Charter](#modifying-this-charter) + +## Values + +The Kmesh and its leadership embrace the following values: + +- Openness: Communication and decision-making happens in the open and is discoverable for future + reference. As much as possible, all discussions and work take place in public + forums and open repositories. + +- Fairness: All stakeholders have the opportunity to provide feedback and submit + contributions, which will be considered on their merits. + +- Community over Product or Company: Sustaining and growing our community takes + priority over shipping code or sponsors' organizational goals. Each + contributor participates in the project as an individual. + +- Inclusivity: We innovate through different perspectives and skill sets, which + can only be accomplished in a welcoming and respectful environment. + +- Participation: Responsibilities within the project are earned through + participation, and there is a clear path up the contributor ladder into leadership + positions. + +## Membership + +The [Community Membership](./membership.md) +outlines responsibilities and requirements for different roles in Kmesh. + +Currently, the approvers are the governing body for the project. This may +change as the community grows, such as by adopting an elected steering committee. + +## Meetings + +Regular meetings are described at [Community Meeting](https://github.com/kmesh-net/community/blob/main/README.md#community-meeting). + +approvers will also have closed meetings in order to discuss security reports +or Code of Conduct violations. Such meetings should be scheduled by any +approvers on receipt of a security issue or CoC report. All current approvers +must be invited to such closed meetings, except for any approvers who is +accused of a CoC violation. + +## Code of Conduct + +[Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md) +violations by community members will be referred to the CNCF Code of Conduct +Committee. Should the CNCF CoC Committee need to work with the project on resolution, the +approvers will appoint a non-involved contributor to work with them. + +## Security Response Team + +The approvers will appoint a Security Response Team to handle security reports. +This committee may simply consist of the approvers Council themselves. If this +responsibility is delegated, the approvers will appoint a team of at least two contributors to handle it. The approvers will review who is assigned to this +at least once a year. + +The Security Response Team is responsible for handling all reports of security +holes and breaches according to the [security policy](https://github.com/kmesh-net/community/blob/main/security-team/SECURITY.md). + +## Voting + +While most business in Kmesh is conducted by "[lazy consensus](https://community.apache.org/committers/lazyConsensus.html)", periodically the approvers may need to vote on specific actions or changes. +A vote can be taken on [the developer mailing list](https://groups.google.com/forum/#!forum/kmesh) or +[community repo issue](https://github.com/kmesh-net/community/issues/new/choose) for security or conduct matters. Votes may also be taken at [the developer meeting](https://github.com/kmesh-net/community/blob/main/README.md#community-meeting). +Any approvers may demand a vote be taken. + +Most votes require a simple majority of all approvers to succeed, except where +otherwise noted. Two-thirds majority votes mean at least two-thirds of all existing approvers. + +## Modifying this Charter + +Changes to this Governance and its supporting documents may be approved by a 2/3 vote of the Approvers. diff --git a/versioned_docs/version-1.2.0/community/membership.md b/versioned_docs/version-1.2.0/community/membership.md new file mode 100644 index 00000000..f6185652 --- /dev/null +++ b/versioned_docs/version-1.2.0/community/membership.md @@ -0,0 +1,111 @@ +--- +title: Membership +sidebar_position: 4 +--- + +:::note +This document keeps changing based on the status and feedback of the Kmesh Community. +::: + +This document provides an overview of Kmesh community roles, along with their requirements, responsibilities, and privileges. + +| Role | Requirements | Responsibilities | Privileges | +| ------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| [Member](#member) | Sponsor from 2 approvers, active in community, contributed to KMesh | Welcome and guide new contributors | KMesh GitHub organization Member | +| [Reviewer](#reviewer) | History of review and authorship in a subproject | Review contributions from community members | Read access to specific packages in relevant repository | +| [Approver](#approver) | Sponsor from 2 maintainers, has good experience and knowledge of domain, actively contributed to code and review | Review and approve contributions from community members | Write access to specific packages in relevant repository | +| [Maintainer](#maintainer) | Sponsor from 2 owners, shown good technical judgment in feature design/development and PR review | Participate in release planning and feature development/maintenance | Top-level write access to relevant repository, name entry in Maintainers file of the repository | + +:::note +All Kmesh community members must follow the Kmesh [Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md). +::: + +## Member + +Members actively contribute by authoring PRs, reviewing issues/PRs, or participating in community discussions on Slack or the mailing list. + +### Requirements + +- Sponsor from 2 approvers +- Enabled [two-factor authentication](https://help.github.com/articles/about-two-factor-authentication) on their GitHub account +- Actively contributed to the community, including: + - Authoring PRs + - Reviewing issues/PRs from other members + - Participating in community discussions + - Attending Kmesh community meetings + +### Responsibilities and Privileges + +- Member of the Kmesh GitHub organization +- Can be assigned to issues and PRs +- Participate in assigned issues and PRs +- Welcome and guide new contributors +- Help new members contribute to Kmesh + +## Reviewer + +Reviewers ensure code quality and correctness for a subproject. + +### Requirements + +- Member for at least 1 month +- Primary reviewer for at least 5 PRs +- Reviewed or merged at least 10 substantial PRs +- Knowledgeable about the codebase +- Sponsored by a subproject approver +- No objections from other approvers +- Added to OWNERS file via PR +- Self-nomination or nomination by an approver + +### Responsibilities and Privileges + +- Responsible for project quality control +- Review code for quality, correctness, and testing +- Respond to review requests +- Assigned PRs and test bugs in their area of expertise +- May receive a badge on PR and issue comments + +## Approver + +Approvers are experienced members who actively review PRs and have strong domain knowledge. + +### Requirements + +- Sponsor from 2 maintainers +- Member for at least 2 months +- Reviewed a substantial number of PRs +- Good codebase knowledge + +### Responsibilities and Privileges + +- Maintain and improve code quality +- Acknowledge and review community PRs +- Approve contributions related to their expertise +- Write access to specific packages in the repository +- Guide and mentor other contributors + +## Maintainer + +Maintainers have demonstrated technical expertise and judgment in feature design and development. + +### Requirements + +- Sponsor from 2 owners +- Approver for at least 2 months +- Nominated by a project owner +- Strong technical judgment in design/development + +### Responsibilities and Privileges + +- Participate in release planning +- Maintain project code quality +- Ensure API compatibility +- Analyze and propose new features/enhancements +- Mentor contributors and approvers +- Top-level write access to the relevant repository +- Listed in the Maintainers file +- Lead design and development of multiple features + +:::note +These roles apply only to the Kmesh GitHub organization and repositories. Currently, Kmesh does not have a formal review process for these roles, but one will be established soon. +::: diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmesh-daemon-map-upgarde.md b/versioned_docs/version-1.2.0/developer-guide/Kmesh-daemon-map-upgarde.md new file mode 100644 index 00000000..e839d4c6 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmesh-daemon-map-upgarde.md @@ -0,0 +1,36 @@ +--- +sidebar_position: 4 +title: Kmesh daemon maps upgrades traffic without disruption +--- + +# Project Documentation: Kmesh daemon maps upgrades traffic without disruption + +## Current strategy + +On upgrade the Kmesh-daemon snapshots the current MapSpec (the `CollectionSpec` embedded by `bpf2go`) to disk. During an upgrade, the daemon reads the previously persisted snapshot as oldMapSpec and performs a strict comparison with the current MapSpec. If the maps are detected as compatible (same type and layout), the daemon reuses the existing pinned map. If they are incompatible, the daemon does not attempt complex live migration; instead it creates a new empty map which is initially pinned to a temporary path and then atomically replaces the original pin by unpinning the old map and renaming the temporary pin to the original path. + +## When traffic without disruption is guaranteed + +### Safe changes + +1. Adding a new map (no changes to existing maps’ properties). + +2. Increasing an existing map’s `MaxEntries` (capacity increase) without changing key/value layout or sizes. + +### Changes that will break traffic without disruption + +1. `Key` type or `Value` type changes, including changes to nested struct definitions. + +2. `KeySize` or `ValueSize` changes (e.g. from 4 bytes to 16 bytes). + +3. Field offset changes (field reorder, delete, rename) or nested struct layout changes that make the layout incompatible. + +4. MapType change (e.g. Hash → Array). + +5. Reducing `MaxEntries`. + +When any of the above changes are detected, the upgrade logic treats the old map as incompatible and creates a new empty map, which causes runtime state loss. + +## Test recommendations + +Package your new daemon build into an image and publish it. Set that image address in the environment variable KMESH_UPGRADE_IMAGE. In a fresh clone of the project , run the e2e test while skipping the test’s internal image build step by passing the --skip-build-daemonupgarde-image flag (this flag tells the test to use the externally supplied KMESH_UPGRADE_IMAGE). The TestKmeshUpgrade test will then perform a rolling upgrade of the daemonset and validate whether traffic continuity is preserved. diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md new file mode 100644 index 00000000..185ecb1d --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/ kmeshctl-authz-disable.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl authz disable +sidebar_position: 2 +--- + +```bash +kmeshctl authz disable [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz disable +kmeshctl authz disable pod1 pod2 +``` + +### Options + +```bash + -h, --help help for disable +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json new file mode 100644 index 00000000..4d4613e3 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Authz", + "position": 7, + "link": { + "type": "generated-index", + "description": "Manage xdp authz eBPF program for Kmesh's authz offloading" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md new file mode 100644 index 00000000..82c9b121 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-enable.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl authz enable +sidebar_position: 1 +--- + +```bash +kmeshctl authz enable [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz enable +kmeshctl authz enable pod1 pod2 +``` + +### Options + +```bash + -h, --help help for enable +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md new file mode 100644 index 00000000..5dc5b17f --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh Authz/kmeshctl-authz-status.md @@ -0,0 +1,21 @@ +--- +title: kmeshctl authz status +sidebar_position: 3 +--- + +```bash +kmeshctl authz status [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz status +kmeshctl authz status pod1 pod2 +``` + +### Options + +```bash + -h, --help help for status +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json new file mode 100644 index 00000000..8d75037c --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Waypoint", + "position": 8, + "link": { + "type": "generated-index", + "description": "A group of commands used to manage waypoint configuration" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md new file mode 100644 index 00000000..100e266c --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/configuration.md @@ -0,0 +1,36 @@ +--- +title: Configuration +sidebar_position: 1 +--- + +Manage waypoint configuration + +### Synopsis + +A group of commands used to manage waypoint configuration + +```bash +kmeshctl waypoint [flags] +``` + +### Examples + +```bash + # Apply a waypoint to the current namespace + kmeshctl waypoint apply + + # Generate a waypoint as yaml + kmeshctl waypoint generate --namespace default + + # List all waypoints in a specific namespace + kmeshctl waypoint list --namespace default +``` + +### Options + +```bash + -h, --help help for waypoint + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md new file mode 100644 index 00000000..63293378 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-apply.md @@ -0,0 +1,42 @@ +--- +title: kmeshctl waypoint apply +sidebar_position: 2 +--- + +Apply a waypoint configuration to the cluster + +```bash +kmeshctl waypoint apply [flags] +``` + +### Examples + +```bash +# Apply a waypoint to the current namespace +kmeshctl waypoint apply + +# Apply a waypoint to a specific namespace and wait for it to be ready +kmeshctl waypoint apply --namespace default --wait + +# Apply a waypoint to a specific pod +kmeshctl waypoint apply -n default --name reviews-v2-pod-waypoint --for workload +``` + +### Options + +```bash + --enroll-namespace If set, the namespace will be labeled with the waypoint name + --for string Specify the traffic type [all none service workload] for the waypoint + -h, --help help for apply + --overwrite Overwrite the existing Waypoint used by the namespace + -r, --revision string The revision to label the waypoint with + -w, --wait Wait for the waypoint to be ready +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md new file mode 100644 index 00000000..24ba6d49 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-delete.md @@ -0,0 +1,41 @@ +--- +title: kmeshctl waypoint delete +sidebar_position: 3 +--- + +Delete a waypoint configuration from the cluster + +```bash +kmeshctl waypoint delete [flags] +``` + +### Examples + +```bash +# Delete a waypoint from the default namespace +kmeshctl waypoint delete + +# Delete a waypoint by name, which can obtain from kmeshctl waypoint list +kmeshctl waypoint delete waypoint-name --namespace default + +# Delete several waypoints by name +kmeshctl waypoint delete waypoint-name1 waypoint-name2 --namespace default + +# Delete all waypoints in a specific namespace +kmeshctl waypoint delete --all --namespace default +``` + +### Options + +```bash + --all Delete all waypoints in the namespace + -h, --help help for delete +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md new file mode 100644 index 00000000..1178f6ed --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-generate.md @@ -0,0 +1,36 @@ +--- +title: kmeshctl waypoint generate +sidebar_position: 4 +--- + +Generate a waypoint configuration as YAML + +```bash +kmeshctl waypoint generate [flags] +``` + +### Examples + +```bash +# Generate a waypoint as yaml +kmeshctl waypoint generate --namespace default + +# Generate a waypoint that can process traffic for service in default namespace +kmeshctl waypoint generate --for service -n default +``` + +### Options + +```bash + --for string Specify the traffic type [all none service workload] for the waypoint + -h, --help help for generate + -r, --revision string The revision to label the waypoint with +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md new file mode 100644 index 00000000..3e887840 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-list.md @@ -0,0 +1,35 @@ +--- +title: kmeshctl waypoint list +sidebar_position: 5 +--- + +List managed waypoint configurations in the cluster + +```bash +kmeshctl waypoint list [flags] +``` + +### Examples + +```bash +# List all waypoints in a specific namespace +kmeshctl waypoint list --namespace default + +# List all waypoints in the cluster +kmeshctl waypoint list -A +``` + +### Options + +```bash + -A, --all-namespaces List all waypoints in all namespaces + -h, --help help for list +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md new file mode 100644 index 00000000..281abad6 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/Kmesh waypoint/kmeshctl-waypoint-status.md @@ -0,0 +1,34 @@ +--- +title: kmeshctl waypoint status +sidebar_position: 6 +--- + +Show the status of waypoints for the namespace provided or default namespace if none is provided + +```bash +kmeshctl waypoint status [flags] +``` + +### Examples + +```bash +# Show the status of the waypoint in the default namespace +kmeshctl waypoint status + +# Show the status of the waypoint in a specific namespace +kmeshctl waypoint status --namespace default +``` + +### Options + +```bash + -h, --help help for status +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json new file mode 100644 index 00000000..af93a8a5 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kmeshctl Usage", + "position": 3, + "link": { + "type": "generated-index", + "description": "Kmesh command line tools to operate and debug Kmesh" + } +} diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md new file mode 100644 index 00000000..bfa31220 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/installation.md @@ -0,0 +1,60 @@ +--- +title: Kmeshctl Installation +sidebar_position: 1 +--- + +## Installation + +### 1. From Release Binaries + +Pre-built binaries are available on our [releases page](https://github.com/kmesh-net/kmesh/releases). + +```bash +# For AMD64 / x86_64 +[ $(uname -m) = x86_64 ] && curl -Lo ./kmeshctl https://github.com/kmesh-net/kmesh/releases/download/v1.0.0/kmeshctl-linux-amd64 +# For ARM64 +[ $(uname -m) = aarch64 ] && curl -Lo ./kmeshctl https://github.com/kmesh-net/kmesh/releases/download/v1.0.0/kmeshctl-linux-arm64 +chmod +x ./kmeshctl +sudo mv ./kmeshctl /usr/local/bin/kmeshctl +``` + +### 2. From Source + +Kmeshctl is still in rapid development. If you want to try the latest features, you can directly build and install it from source. + +```bash +# Clone source code from github +git clone https://github.com/kmesh-net/kmesh.git + +# Build and install kmeshctl +cd kmesh/ +make kmeshctl +chmod +x ./kmeshctl +sudo mv ./kmeshctl /usr/local/bin/kmeshctl +``` + +## Commands Reference + +### kmeshctl accesslog + +Enable or disable Kmesh's accesslog + +```bash +kmeshctl accesslog [flags] +``` + +**Examples** + +```bash +# Enable Kmesh's accesslog: +kmeshctl accesslog enable + +# Disable Kmesh's accesslog: +kmeshctl accesslog disable +``` + +**Options** + +```bash + -h, --help help for accesslog +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md new file mode 100644 index 00000000..58d3bf89 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-dump.md @@ -0,0 +1,26 @@ +--- +title: Kmeshctl Dump +sidebar_position: 3 +--- + +Dump config of kernel-native or dual-engine mode + +```bash +kmeshctl dump [flags] +``` + +### Examples + +```bash +# Kernel Native mode: +kmeshctl dump kernel-native + +# Dual Engine mode: +kmeshctl dump dual-engine +``` + +### Options + +```bash + -h, --help help for dump +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md new file mode 100644 index 00000000..4108bbe4 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-log.md @@ -0,0 +1,30 @@ +--- +title: Kmeshctl Log +sidebar_position: 5 +--- + +Get or set kmesh-daemon's logger level + +```bash +kmeshctl log [flags] +``` + +### Examples + +```bash +# Set default logger's level as "debug": +kmeshctl log --set default:debug + +# Get all loggers' name +kmeshctl log + +# Get default logger's level: +kmeshctl log default +``` + +### Options + +```bash + -h, --help help for log + --set string Set the logger level (e.g., default:debug) +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-monitoring.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-monitoring.md new file mode 100644 index 00000000..0e6e6866 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-monitoring.md @@ -0,0 +1,50 @@ +--- +title: Kmeshctl Monitoring +sidebar_position: 4 +--- + +Control Kmesh's monitoring to be turned on as needed + +```bash +kmeshctl monitoring [flags] +``` + +### Examples + +```bash +# Enable/Disable Kmesh's accesslog: +kmeshctl monitoring --accesslog enable/disable + +# Enable/Disable services' metrics and accesslog generated from bpf: +kmeshctl monitoring --all enable/disable + +# Enable/Disable workload granularity metrics: +kmeshctl monitoring --workloadMetrics enable/disable + +# Enable/Disable connection granularity metrics: +kmeshctl monitoring --connectionMetrics enable/disable + +# If you want to change the monitoring functionality of all kmesh daemons in the cluster +# Enable/Disable Kmesh's accesslog in each node: +kmeshctl monitoring --accesslog enable/disable + +# Enable/Disable workload granularity metrics in each node: +kmeshctl monitoring --workloadMetrics enable/disable + +# Enable/Disable connection granularity metrics in each node: +kmeshctl monitoring --connectionMetrics enable/disable + +#Enable/Disable services', workloads' and 'connections' metrics and accesslog generated from bpf in each node: +kmeshctl monitoring --all enable/disable +``` + +### Options + +```bash + --accesslog string Control accesslog enable or disable + --all string Control accesslog and services' and workloads' metrics enable or disable together + + --connectionMetrics string Control connection granularity metrics enable or disable + -h, --help help for monitoring + --workloadMetrics string Control workload granularity metrics enable or disable +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md new file mode 100644 index 00000000..6066bb60 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-secret.md @@ -0,0 +1,104 @@ +--- +title: kmeshctl secret +sidebar_position: 6 +--- + +### Use IPsec in Kmesh cluster + +IPsec is a mature and widely used encryption method for inter-node communication. This document explains how to enable IPsec to encrypt communication data between Kmesh-managed nodes. + +### kmeshctl secret command Examples + +The `kmeshctl secret` command provides management capabilities for IPsec secrets in Kmesh clusters. It supports the following subcommands: + +- `create`: Generate and store IPsec key and configuration +- `get`: Retrieve current IPsec key and configuration (displayed in JSON format) +- `delete`: Remove IPsec secret from the cluster + +#### Basic usage examples + +```bash +# Create IPsec secret with random key +kmeshctl secret create + +# Create IPsec secret with custom key +kmeshctl secret create --key=$(echo -n "{36-character user-defined key here}" | xxd -p -c 64) + +# Get current IPsec configuration +kmeshctl secret get + +# Delete IPsec secret +kmeshctl secret delete +``` + +### How to enable IPsec in Kmesh + +#### Step 1: Generate an IPsec pre-shared key for Kmesh before starting Kmesh. Currently, only the rfc4106 (gcm(AES)) algorithm is supported. The key must be 36 bytes (32 bytes for the algorithm key and 4 bytes for the salt), provided as a 72-character hexadecimal string + +If you want to use a randomly generated key, you can use the following command: + +``` bash +kmeshctl secret create +``` + +If you want to use a custom key, you can use the following command: + +``` bash +kmeshctl secret create --key=$(echo -n "{36-character user-defined key here}" | xxd -p -c 64) +``` + +#### Step 2: Add the parameter --enable-ipsec=true to the Kmesh yaml + +```plaintext +kmesh.yaml +... +args: +[ + "./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true", +] +... +``` + +#### Step 3: Place pods or namespace under the management of Kmesh + +Only when both communicating pods are managed by Kmesh, will they enter the encryption process. + +``` bash +kubectl label namespace default istio.io/dataplane-mode=Kmesh +``` + +#### Step 4: Test whether the data packet has been encrypted + +Use tcpdump on nodes to capture packets and check if IPsec has been used during data communication between nodes (determined by ESP packets) + +```plaintext +tcpdump -i any |grep ESP +... +14:19:24.143654 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da88), length 80 +14:19:24.143690 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da89), length 80 +14:19:24.143707 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c037), length 80 +14:19:24.143738 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c038), length 172 +... +``` + +#### Step 5: Replace pre-shared key + +After a period of time, the pre-shared key of the cluster can be changed. After changing the pre-shared key, the ESP SPI number of the IPsec used for communication between nodes will be increased by 1 compared to the previous version. This can be observed again through using tcpdump. The initial IPsec SPI version number is 1. + +To replace the existing pre-shared key, run the `kmeshctl secret create` command again. + +```plaintext +root@master:~/kmesh# tcpdump -i any |grep ESP +... +14:26:33.782665 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa1), length 80 +14:26:33.782666 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa2), length 80 +14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d2), length 80 +14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d3), length 80 +... +``` + +### Note + +1. IPsec encryption uses mark `0xe0` and `0xd0` as markers for IPsec encryption and decryption. Please ensure that no conflicting Mark is used on the host network, otherwise unknown behavior may occur + +2. Please ensure that `address MASQ` is not used on packets encrypted with IPsec. After address MASQ, IPsec cannot accurately match encryption and decryption rules, which can result in packet loss diff --git a/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md new file mode 100644 index 00000000..faa32e6d --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Kmeshctl-usage/kmeshctl-version.md @@ -0,0 +1,26 @@ +--- +title: Kmeshctl Version +sidebar_position: 2 +--- + +Prints out build version info + +```bash +kmeshctl version [flags] +``` + +### Examples + +```bash +# Show version of kmeshctl +kmeshctl version + +# Show version info of a specific Kmesh daemon +kmeshctl version +``` + +### Options + +```bash + -h, --help help for version +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-quickstart.md b/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-quickstart.md new file mode 100644 index 00000000..ac0fe896 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-quickstart.md @@ -0,0 +1,129 @@ +# Quickstart for Kmesh E2E Testing + +This document is designed to help developers quickly get started with writing and running end-to-end (E2E) tests for the Kmesh project. It covers the prerequisites, the test environment setup, a simple test function template, and instructions for running tests. By following this guide, you will be able to write and execute E2E tests efficiently, ensuring the stability and correctness of Kmesh features. + +## Prerequisites + +Before getting started, ensure the following tools are installed in your environment: + +- **Go**: For running the test framework. +- **Docker**: For containerizing applications. +- **kubectl**: For managing Kubernetes clusters. +- **Kind**: For creating Kubernetes clusters locally. +- **Helm**: For managing Kubernetes applications. + +## E2E Test Environment + +Kmesh E2E testing requires a two-node KinD cluster: + +- **Control Node**: Manages the cluster. +- **Worker Node**: Runs the test services. + +At the start of the test, two services will be deployed: + +1. **service-with-waypoint-at-service-granularity**: A service with a Waypoint. +2. **enrolled-to-kmesh**: A service without a Waypoint. + +Both services use Echo Pods, which are used to test different scenarios. + +## Writing E2E Tests + +Here is a simple E2E test function template with step-by-step explanations: + +```go +func TestEchoCall(t *testing.T) { + // Create a new test suite for the current test + framework.NewTest(t).Run(func(t framework.TestContext) { + // Define a subtest for the Echo Call functionality + t.NewSubTest("Echo Call Test").Run(func(t framework.TestContext) { + // Retrieve the source service (with Waypoint) and destination service (without Waypoint) + src := apps.ServiceWithWaypointAtServiceGranularity[0] + dst := apps.EnrolledToKmesh + + // Define test cases with a name and a checker to validate the response + cases := []struct { + name string + checker echo.Checker + }{ + { + name: "basic call", // Name of the test case + checker: echo.And( + echo.ExpectOK(), // Expect the HTTP call to succeed + echo.ExpectBodyContains("Hello"), // Expect the response body to contain "Hello" + ), + }, + } + + // Iterate over each test case and execute it + for _, c := range cases { + t.NewSubTest(c.name).Run(func(t framework.TestContext) { + // Perform the HTTP call from the source to the destination + src.CallOrFail(t, echo.CallOptions{ + Target: dst[0], // Target service + PortName: "http", // Port name to use for the call + Checker: c.checker, // Checker to validate the response + }) + }) + } + }) + }) +} +``` + +### Explanation of Steps + +1. **`framework.NewTest(t).Run`**: Initializes a new test suite for the current test. +2. **`t.NewSubTest("Echo Call Test").Run`**: Creates a subtest for the Echo Call functionality. +3. **Retrieve Services**: The `src` variable represents the source service (with Waypoint), and the `dst` variable represents the destination service (without Waypoint). +4. **Define Test Cases**: Each test case includes a name and a `checker` to validate the HTTP response. For example, `echo.ExpectOK()` ensures the HTTP call succeeds, and `echo.ExpectBodyContains("Hello")` checks the response body. +5. **Iterate and Execute**: For each test case, the `src.CallOrFail` method performs the HTTP call from the source to the destination and validates the response using the specified `checker`. +6. **`echo.CallOptions`**: Specifies the target service, port name, and checker for the HTTP call. + +### Resource Cleanup + +Use the `t.Cleanup` method to ensure test resources are cleaned up after the test completes. For example: + +```go +t.Cleanup(func() { + // Clean up resources +}) +``` + +### Deploying Policies + +Use the `t.ConfigIstio` method to deploy policies required for the test. For example: + +```go +t.ConfigIstio().YAML("test-namespace", ` +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: allow-all +spec: + rules: + - {} +`).ApplyOrFail(t) +``` + +### Using echo.Checker + +`echo.Checker` is used to verify whether a test case passes. For example: + +```go +// Example: Using echo.Checker to validate HTTP response +src.CallOrFail(t, echo.CallOptions{ + Target: dst[0], + PortName: "http", + Checker: echo.And( + echo.ExpectOK(), // Expect the HTTP call to succeed + echo.ExpectBodyContains("Hello"), // Expect the response body to contain "Hello" + echo.ExpectHeaders(map[string]string{ + "Content-Type": "text/plain", // Expect the Content-Type header to be "text/plain" + }), + ), +}) +``` + +## Running Tests + +For detailed instructions on running tests, refer to the [E2E Test Guide](https://kmesh.net/docs/developer-guide/Tests/e2e-test). diff --git a/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-test.md b/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-test.md new file mode 100644 index 00000000..c53ee5db --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Tests/e2e-test.md @@ -0,0 +1,108 @@ +--- +title: Run E2E test +sidebar_position: 2 +--- + +End-to-End (E2E) testing is a crucial component in modern software development, designed to simulate user interactions across the entire application to ensure all components and integrations function together seamlessly. By incorporating E2E testing, we can verify that changes in code do not disrupt existing functionalities, maintaining the integrity and reliability of the system even as it evolves. + +## Prerequisites + +Components that need to be installed by the user: + +- Go +- Docker +- Kubectl + +The following components will be installed while using the shell: + +- Kind +- Helm +- Istioctl + +## Usage + +To run the E2E tests, execute the `run_test.sh` script located in the `./test/e2e` directory. This script automates the following tasks: + +1. **Installing dependencies:** Tools like Kind, Helm and Istioctl ... +2. **Deploying a local image registry:** A Docker container functions as the local image registry. +3. **Building and pushing the Kmesh image:** The custom Kmesh Docker image is built and pushed to the local registry. +4. **Deploying Kubernetes cluster, Istio, and Kmesh:** These components are necessary for the tests and are set up in this step. +5. **Deploying test applications and executing the E2E tests.** + +## Command Line Flags + +When testing locally, you may want to skip some setup steps to save time, especially after the initial setup is complete. The following flags are available to customize the test execution: + +- **--skip-install-dep** : Skips the installation of dependencies. +- **--skip-build** : Skips building and pushing the Kmesh image to the local image registry. +- **--skip-setup** : Skips deploying the Kubernetes cluster, Istio, and Kmesh. +- **--only-run-tests** : Skips all other steps and focuses only on deploying test applications and running E2E tests. +- **--cluster** : Allows specifying a pre-existing KinD cluster by name. +- **--ipv6** : Enables creating a KinD cluster with IPv6 networking and run E2E tests on it. +- **--cleanup** : Cleans up the KinD cluster and local registry after tests are completed. +- **--skip-cleanup-apps** : Skips the cleanup of test applications after the tests have been executed. +- Directly use **go test** command-line arguments when running the tests + +### Example Commands + +#### Full Test Run (First time) + +```bash +./test/e2e/run_test.sh +``` + +Use this command for the initial setup and test run to ensure everything is configured correctly. + +#### Subsequent Test Runs (Skipping all setup and only run tests) + +```bash +./test/e2e/run_test.sh --only-run-tests +``` + +You might need different kinds of tests. + +#### Specifying a Pre-existing KinD Cluster + +```bash +./test/e2e/run_test.sh --cluster +``` + +#### Create a IPv6 KinD cluster and Run Tests + +```bash +./test/e2e/run_test.sh --ipv6 +``` + +In some cases, you might want to clean up some resources after the tests, while in other cases, you might want to skip cleaning up test applications for further usage. + +#### Cleanup the KinD Cluster and Docker Registry After Tests + +```bash +./test/e2e/run_test.sh --cleanup +``` + +#### Skip the Cleanup of Test Applications After Tests + +```bash +./test/e2e/run_test.sh --skip-cleanup-apps +``` + +You can also directly use go test command-line arguments when running the tests. For example, you can filter specific tests, or control other aspects of the testing process directly from the command line. + +#### Selecting Specific Test Cases + +```bash +./test/e2e/run_test.sh --only-run-tests -run "TestServices" +``` + +#### Controlling Test Verbosity + +```bash +./test/e2e/run_test.sh -v +``` + +#### Repeat Test Cases Multiple Times + +```bash +./test/e2e/run_test.sh -count=3 +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Tests/ipsec-auth-e2e-test.md b/versioned_docs/version-1.2.0/developer-guide/Tests/ipsec-auth-e2e-test.md new file mode 100644 index 00000000..b67c156f --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Tests/ipsec-auth-e2e-test.md @@ -0,0 +1,319 @@ +# IPSec & Offload Authorization E2E Test Guide + +This document provides a step-by-step guide for executing the IPSec and Offload Authorization E2E tests for Kmesh. These tests ensure the reliability, security, and functionality of the IPSec feature and the Offload Authorization mechanisms. + +## Prerequisites + +Before running the tests, ensure the following: + +- **Kubernetes Cluster**: A two-node Kubernetes cluster with Kmesh installed. +- **Tools**: `kubectl`, `tcpdump`, and `kmeshctl`. +- **Applications**: `echo` and `sleep` applications deployed in the cluster. + +## Example YAML for Deployment + +**Sleep Application (save as `sleep.yaml`):** + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: sleep + labels: + app: sleep +spec: + ports: + - port: 80 + name: http + selector: + app: sleep +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sleep +spec: + replicas: 1 + selector: + matchLabels: + app: sleep + template: + metadata: + labels: + app: sleep + spec: + nodeName: kmesh-testing-control-plane + containers: + - name: sleep + image: curlimages/curl + command: ["/bin/sleep", "infinity"] +``` + +**Echo Application (save as `echo.yaml`):** + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: echo +spec: + ports: + - name: http + port: 80 + targetPort: 8080 + selector: + app: echo +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: echo +spec: + replicas: 1 + selector: + matchLabels: + app: echo + template: + metadata: + labels: + app: echo + spec: + containers: + - name: echo + image: gcr.io/istio-testing/app:latest + args: + - --port=8080 + ports: + - containerPort: 8080 +``` + +## IPSec E2E Tests + +### 1. Basic Connectivity Test + +This test verifies the establishment of IPSec tunnels and the correctness of encrypted communication. + +#### Steps + +1. Deploy the `sleep` and `echo` applications: + + ```bash + kubectl apply -f sleep.yaml + kubectl apply -f echo.yaml + ``` + +2. Verify connectivity between the applications: + + ```bash + kubectl exec -- curl http:// + ``` + + **Expected Output:** + + ```plaintext + Hello version: v1, instance: echo- + ``` + +3. Check IPSec state: + + ```bash + ip xfrm state show + ``` + + **Expected Output:** + + ```plaintext + src {{SRC_IP}} dst {{DST_IP}} + proto esp spi 0x{{SPI}} reqid 1 mode tunnel + replay-window 0 + output-mark 0xd0/0xffffffff + aead rfc4106(gcm(aes)) {{KEY}} 128 + anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000 + sel src ::/0 dst ::/0 + ``` + +4. Check IPSec policy: + + ```bash + ip xfrm policy show + ``` + + **Expected Output:** + + ```plaintext + src ::/0 dst {{DST_SUBNET}} + dir out priority 0 + mark 0xe0/0xffffffff + tmpl src {{SRC_IP}} dst {{DST_IP}} + proto esp spi 0x{{SPI}} reqid 1 mode tunnel + ``` + +5. Verify encryption using `tcpdump`: + + ```bash + tcpdump -i any esp + ``` + + **Expected Output:** ESP packets should be visible during communication. + +### 2. Key Rotation Test + +This test ensures the reliability of the PSK update mechanism and validates service continuity during key changes. + +#### Steps + +1. Record the initial SPI: + + ```bash + ip xfrm state show + ``` + + **Expected Output:** + + ```plaintext + src {{SRC_IP}} dst {{DST_IP}} + proto esp spi 0x{{INITIAL_SPI}} reqid 1 mode tunnel + aead rfc4106(gcm(aes)) {{INITIAL_KEY}} 128 + ``` + +2. Send continuous traffic between the applications: + + ```bash + kubectl exec -- curl http:// + ``` + +3. Update the pre-shared key: + + ```bash + kmeshctl secret create --key= + ``` + +4. Verify that the SPI and key are updated in the xfrm rules: + + ```bash + ip xfrm state show + ``` + + **Expected Output:** + + ```plaintext + src {{SRC_IP}} dst {{DST_IP}} + proto esp spi 0x{{INITIAL_SPI + 1}} reqid 1 mode tunnel + aead rfc4106(gcm(aes)) {{NEW_KEY}} 128 + ``` + +5. Ensure communication continuity and encryption status. + +## Offload Authorization E2E Tests + +### Unified Steps for Authorization Tests + +1. Apply the policy: + + ```bash + kubectl apply -f .yaml + ``` + +2. Test connectivity: + + ```bash + kubectl exec -- curl http:// + ``` + + **Expected Output:** + + - **ALLOW Policy:** The curl command should succeed, and the HTTP response code should be `200`. + - **DENY Policy:** The curl command should fail, and no response should be received. + +### Example Policies + +#### IP Authorization Policy + +```yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: ip-allow-policy + namespace: test-ns1 +spec: + action: ALLOW + rules: + - from: + - source: + ipBlocks: + - "{{ALLOWED_IP}}" +``` + +#### Port Authorization Policy + +```yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: port-allow-policy + namespace: test-ns1 +spec: + action: ALLOW + rules: + - to: + - operation: + ports: ["{{ALLOWED_PORT}}"] +``` + +#### Header Authorization Policy + +```yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: header-allow-policy + namespace: test-ns1 +spec: + action: ALLOW + rules: + - when: + - key: request.headers["{{HEADER_NAME}}"] + values: ["{{HEADER_VALUE}}"] +``` + +#### Namespace Authorization Policy + +```yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: namespace-allow-policy + namespace: test-ns1 +spec: + action: ALLOW + rules: + - from: + - source: + namespaces: ["{{SOURCE_NAMESPACE}}"] +``` + +#### Host Authorization Policy + +```yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: host-allow-policy + namespace: test-ns1 +spec: + action: ALLOW + rules: + - to: + - operation: + hosts: ["{{TARGET_HOST}}"] +``` + +## Cleanup + +After completing the tests, clean up the resources: + +```bash +kubectl delete -f sleep.yaml +kubectl delete -f echo.yaml +kubectl delete authorizationpolicy --all -n test-ns1 +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/Tests/unit-test.md b/versioned_docs/version-1.2.0/developer-guide/Tests/unit-test.md new file mode 100644 index 00000000..d4ce3ecb --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/Tests/unit-test.md @@ -0,0 +1,119 @@ +--- +title: Run Unit test +sidebar_position: 1 +--- + +# Run Unit Test + +Compiling Kmesh directly in the operating system requires a certain [OS version](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md). Therefore, in order to allow all operating systems to run Kmesh's UT, Kmesh provides two ways to do so. One to run the go unit test in docker and one to run the go unit test locally. + +Developers of unsupported kernel version can run go unit test in docker through script. Developers of supported version can run go unit test locally through script. + +```sh +cd $(Kmesh root directory) + +# Run kmesh ut through docker +./hack/run-ut.sh --docker + +# Run kmesh ut locally +./hack/run-ut.sh --local +``` + +Alternatively, you can execute the test by `make test`: + +```sh +# Run kmesh ut through docker +make test RUN_IN_CONTAINER=1 + +# Run kmesh ut locally +make test RUN_IN_CONTAINER=0 +``` + +## Unit test + +This section describes the ut settings for Kmesh so that developers can run unit tests without using scripts. + +Because Kmesh uses eBPF, you need to set some environment variables when running Kmesh-related Unit Tests. + +```sh +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$ROOT_DIR/api/v2-c:$ROOT_DIR/bpf/deserialization_to_bpf_map +export PKG_CONFIG_PATH=$ROOT_DIR/mk +``` + +Set `LD_LIBRARY_PATH` so that the system can find the .so files. + +Set `PKG_CONFIG_PATH` so that the system can find the .pc files that Kmesh compiled. + +In addition to this, you may also encounter a c header file not found error. Such errors can be resolved by setting `C_INCLUDE_PATH`. The header files needed for Kmesh are saved in the [bpf](https://github.com/kmesh-net/kmesh/tree/main/bpf) folder. + +Note the **multiple header file** problem. + +### Common Issues and Solutions for Running Unit Tests + +When running unit tests in the `/test/bpf_ut/bpftest` directory, you might encounter the following issues and their solutions. To avoid repeated settings, it is recommended to use a unified `sudo env` command to execute the tests. + +1. **`go` command not found** + + In a `sudo` environment, the `go` command might not be found in the `PATH`. + * **Solution**: Explicitly pass the `PATH` environment variable in the `sudo` command, e.g., `PATH=$PATH:/usr/local/go/bin`. + +2. **Go module download issue (network timeout)** + + For example, encountering `Get "https://proxy.golang.org/..." i/o timeout`. This is usually caused by network proxy or connection problems preventing Go modules from being downloaded. + * **Solution**: Set `GOPROXY` to use a domestic proxy and disable `GOSUMDB` verification, e.g., `GOPROXY=https://goproxy.cn,direct GOSUMDB=off`. + +3. **`No package 'api-v2-c' found`** + + This indicates that `pkg-config` cannot find the `api-v2-c.pc` file. + * **Solution**: Find the actual path of the `api-v2-c.pc` file and add its directory to the `PKG_CONFIG_PATH` environment variable. In the Kmesh project, this file is usually located in the `mk/` directory. + + ```sh + # Find the .pc file + find {your-project-path} -name "api-v2-c.pc" + # Example output: {your-project-path}/mk/api-v2-c.pc + # Set PKG_CONFIG_PATH + export PKG_CONFIG_PATH={your-project-path}/mk:$PKG_CONFIG_PATH + # Verify (optional) + pkg-config --cflags api-v2-c + ``` + +4. **`libkmesh_api_v2_c.so: cannot open shared object file: No such file or directory` (Dynamic library not found)** + + This usually happens at runtime when the system cannot find the `.so` dynamic library file compiled by Kmesh. + * **Solution**: Determine the directory where the `.so` file is located (e.g., `/usr/lib64`) and add it to the `LD_LIBRARY_PATH` environment variable, e.g., `LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH`. + +**Unified Unit Test Execution Command Example**: + +To resolve the above common issues, you can use the following command with all necessary environment variables to run unit tests: + +```sh +sudo env \ + PKG_CONFIG_PATH={your-project-path}/mk:$PKG_CONFIG_PATH \ + GOPROXY=https://goproxy.cn,direct \ + GOSUMDB=off \ + PATH=$PATH:/usr/local/go/bin \ + LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH \ + make run +``` + +If you want to see more detailed test output, you can add the `-test.v` parameter: + +```sh +sudo env \ + PKG_CONFIG_PATH={your-project-path}/mk:$PKG_CONFIG_PATH \ + GOPROXY=https://goproxy.cn,direct \ + GOSUMDB=off \ + PATH=$PATH:/usr/local/go/bin \ + LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH \ + go test ./bpftest -bpf-ut-path {your-project-path}/test/bpf_ut -test.v +``` + +Please adjust based on the actual root directory path of your Kmesh project (e.g., `{your-project-path}`) and the path to the `.so` dynamic library file (e.g., `/usr/lib64`). + +Besides the above issues, since Kmesh ut uses gomonkey, there may be a situation where monkey's functions are small and inlined during Go compilation optimization. + +We can solve this problem by adding the following parameter to the go test execution: + +```bash +-gcflags="all=-N -l" +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/_category_.json b/versioned_docs/version-1.2.0/developer-guide/_category_.json new file mode 100644 index 00000000..f1426c17 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Developer Guide", + "position": 7, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/developer-guide/build-guide.md b/versioned_docs/version-1.2.0/developer-guide/build-guide.md new file mode 100644 index 00000000..7b8c8035 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/build-guide.md @@ -0,0 +1,133 @@ +--- +sidebar_position: 1 +title: "How to build" +--- + +The Kmesh needs to be compiled and built in the Linux environment with the Kmesh kernel enhancement feature. Currently, Kmesh can be compiled and run in multiple OS versions, and the specific OS versions can see [Kmesh support system](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md). + +## Build + +### Prerequisite + +- Install docker-engine + + ```sh + sudo apt-get update + (optional)sudo apt-get remove docker docker-engine docker.io + sudo apt install docker.io + ``` + + You can check the docker version to make sure that docker is installed. + + ```sh + docker version + Client: Docker Engine - Community + Version: 26.0.1 + API version: 1.45 + Go version: go1.21.9 + Git commit: d260a54 + Built: Thu Apr 11 10:53:21 2024 + OS/Arch: linux/amd64 + Context: default + + Server: Docker Engine - Community + Engine: + Version: 26.0.1 + API version: 1.45 (minimum version 1.24) + Go version: go1.21.9 + Git commit: 60b9add + Built: Thu Apr 11 10:53:21 2024 + OS/Arch: linux/amd64 + Experimental: false + containerd: + Version: 1.6.31 + GitCommit: e377cd56a71523140ca6ae87e30244719194a521 + runc: + Version: 1.1.12 + GitCommit: v1.1.12-0-g51d5e94 + docker-init: + Version: 0.19.0 + GitCommit: de40ad0 + ``` + +- Download Kmesh-build image + + To compile the Kmesh image, you need to prepare the Kmesh source code and the Kmesh-build image. The image can be obtained using the following command: + + ```sh + docker pull ghcr.io/kmesh-net/kmesh-build-x86:latest + ``` + + Note: The `Kmesh-build` image needs to match the version of the source code. + +### Build Kmesh from Source + +Clong the source code from github. + +```sh +git clone https://github.com/kmesh-net/kmesh.git +``` + +Code compilation + +- Compile Kmesh through build-image + + ```sh + cd kmesh/ + make build + ``` + +- Compile Kmesh through script + + Kmesh also provides a way to compile through scripts + + ```sh + [root@dev] ./kmesh_compile.sh + ``` + + Note that if you use script to compile, you need to make sure that your os system version is one that [Kmesh supports system](https://github.com/kmesh-net/kmesh/blob/main/docs/kmesh_support.md)! + +When Kmesh compilation is finish, the build artifacts will be output to the `out` directory. + +```bash +ls out/amd64/ +kmesh-daemon libbpf.so libbpf.so.0.8.1 libkmesh_deserial.so libprotobuf-c.so.1 mdacore +kmesh-cni libboundscheck.so libbpf.so.0 libkmesh_api_v2_c.so libprotobuf-c.so libprotobuf-c.so.1.0.0 +``` + +### Build Docker Image + +Execute `make docker` in the Kmesh source code directory. + +Users can specify parameters for building, as shown in the example below: + +```sh +User-defined HUB, TARGET, TAG values. If not specified, default values will be used. +HUB=ghcr.io/kmesh-net +TARGET=kmesh +TAG= #git sha + +[root@dev docker] make docker +... +Successfully tagged ghcr.io/kmesh-net/kmesh:b68790eb07830e757f4ce6d1c478d0046ee79730 + +[root@dev docker] make docker HUB=ghcr.io/kmesh-net TARGET=kmesh TAG=latest +... +Successfully tagged ghcr.io/kmesh-net/kmesh:latest +``` + +Check the existing Kmesh image in the local image repository: + +```sh +[root@dev docker]# docker images ls +REPOSITORY TAG IMAGE ID CREATED SIZE +ghcr.io/kmesh-net/kmesh latest 71aec5898c44 About an hour ago 506MB +``` + +### Compilation Cleanup + +You can use the following command to clean up the binaries. + +```sh +[root@dev] make clean +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/traffic-spilt.md b/versioned_docs/version-1.2.0/developer-guide/traffic-spilt.md new file mode 100644 index 00000000..bb2941df --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/traffic-spilt.md @@ -0,0 +1,104 @@ +--- +sidebar_position: 2 +title: Traffic Split +--- + +### Before you begin + +#### Install Kmesh in Kernel-Native Mode + +1. Navigate to the [quickstart](/docs/setup/quick-start.md) documentation +2. In the section titled `Change Kmesh Start Mode` +3. Open the configuration file: `deploy/charts/kmesh-helm/values.yaml` +4. Replace `--mode=dual-engine` with `--mode=kernel-native` + +This configuration change is required for the traffic split functionality to work properly. + +#### Deploy the Sample Applications + +```shell +[root@master kmesh]# kubectl apply -f samples/sleep/sleep.yaml -n tcp-echo-test +[root@master kmesh]# kubectl apply -f samples/tcp-echo/tcp-echo-services.yaml -n tcp-echo-test +[root@master kmesh]# kubectl apply -f samples/tcp-echo/tcp-echo-virtualservice.yaml -n tcp-echo-test +``` + +### Apply weight-based Load Balance + +1. Let Kmesh manage the traffic of pods + + ```shell + [root@master test]# kubectl label ns default istio.io/dataplane-moda=Kmesh + ``` + +2. Confirm that the `tcp-echo` service is up and running by sending some TCP traffic. + + ```shell + ##get tcp-echo service address + [root@master test]# kubectl get svc | grep tcp- + tcp-echo ClusterIP 10.96.128.249 9000/TCP,9001/TCP 43h + [root@master test]# for i in {1..20}; do kubectl exec sleep-78ff5975c6-cm8hd -c sleep -- sh -c "(date; sleep 1) | nc 10.96.128.249:9000;" done + two Sat Jul 6 08:46:45 UTC 2024 + two Sat Jul 6 08:46:46 UTC 2024 + one Sat Jul 6 08:46:47 UTC 2024 + one Sat Jul 6 08:46:48 UTC 2024 + two Sat Jul 6 08:46:49 UTC 2024 + two Sat Jul 6 08:46:51 UTC 2024 + two Sat Jul 6 08:46:52 UTC 2024 + one Sat Jul 6 08:46:53 UTC 2024 + two Sat Jul 6 08:46:54 UTC 2024 + two Sat Jul 6 08:46:55 UTC 2024 + one Sat Jul 6 08:46:56 UTC 2024 + one Sat Jul 6 08:46:57 UTC 2024 + two Sat Jul 6 08:46:58 UTC 2024 + one Sat Jul 6 08:47:00 UTC 2024 + two Sat Jul 6 08:47:01 UTC 2024 + one Sat Jul 6 08:47:02 UTC 2024 + two Sat Jul 6 08:47:03 UTC 2024 + one Sat Jul 6 08:47:04 UTC 2024 + one Sat Jul 6 08:47:05 UTC 2024 + two Sat Jul 6 08:47:06 UTC 2024 + ``` + +### Dump the configuration information + +```shell +[root@master kmesh]# ./kmeshctl dump kmesh-5f4fm kernel-native +``` + +After dump the configuration, we can see that the strategy is load balancing. + +```json +{ + "name": "outbound|9001||tcp-echo.default.svc.cluster.local", + "connectTimeout": 10, + "lbPolicy": "LEAST_REQUEST", + "loadAssignment": { + "clusterName": "outbound|9001||tcp-echo.default.svc.cluster.local", + "endpoints": [ + { + "lbEndpoints": [ + { + "address": { + "port": 10531, + "ipv4": 469890058 + } + }, + { + "address": { + "port": 10531, + "ipv4": 453112842 + } + } + ], + "loadBalancingWeight": 2 + } + ] + }, + "circuitBreakers": { + "maxConnections": 4294967295, + "maxPendingRequests": 4294967295, + "maxRequests": 4294967295, + "maxRetries": 4294967295 + } +} +``` diff --git a/versioned_docs/version-1.2.0/developer-guide/website/create-blog.md b/versioned_docs/version-1.2.0/developer-guide/website/create-blog.md new file mode 100644 index 00000000..e6d9d7e8 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/website/create-blog.md @@ -0,0 +1,240 @@ +--- +title: Create a Blog +sidebar_position: 3 +--- + +## Creating a Blog in Docusaurus: A Comprehensive Guide + +Docusaurus is a powerful static site generator that includes a built-in blog feature, making it easy to create and share blog posts. This guide will explain how to set up a blog, write posts, configure options, and maintain your content—all in a way that's approachable for beginners. + +### 1. What Is the Blog Feature in Docusaurus? + +The blog feature in Docusaurus allows you to: + +- Write blog posts as Markdown files. +- Automatically generate a blog index page listing all your posts. +- Create individual pages for each blog post. +- Customize how your blog looks and behaves. + +It’s perfect for sharing project updates, tutorials, or any time-based content, with minimal setup required. + +### 2. Blog Folder Structure + +In a Docusaurus project, blog posts are stored in the `blog/` directory. Each post is a separate Markdown file, and the file name typically includes the publication date and a slug (a URL-friendly title). Here’s an example structure: + +```text +blog/ +├── 2023-10-05-my-first-post.md +└── 2023-10-06-another-post.md +``` + +- **Date**: The `YYYY-MM-DD` part (e.g., `2023-10-05`) sets the post’s publication date and order. +- **Slug**: The part after the date (e.g., `my-first-post`) becomes part of the URL (e.g., `/blog/my-first-post`). + +You can keep all posts in the `blog/` directory or use subfolders for organization (though a flat structure works fine for most cases). + +### 3. Writing Blog Posts: Front Matter + +Every blog post starts with a **front matter** section—a YAML block at the top of the file, enclosed in triple dashes (`---`). This section contains metadata about the post. Here’s an example: + +```yaml +--- +title: My First Blog Post +date: 2023-10-05 +author: John Doe +tags: ["example", "blog"] +--- +``` + +Key fields include: + +- **`title`**: The post’s title, shown on the post page and blog index. +- **`date`**: The publication date (must match the file name’s date). +- **`author`**: The author’s name (optional). +- **`tags`**: A list of tags for categorization (optional). + +The front matter is essential for Docusaurus to recognize and display your post correctly. + +### 4. Writing Blog Post Content + +After the front matter, write your post’s content using Markdown. Docusaurus supports standard Markdown syntax—headings, lists, links, images, and more. Here’s an example: + +```markdown +# My First Blog Post + +Welcome to my blog! + +## Why I Started This Blog + +I’m excited to share my experiences. Here’s why: + +- To document my progress +- To connect with others +- To learn from feedback + +## What’s Next? + +Look out for posts on: + +1. Project setup tips +2. Coding best practices +3. Fun experiments +``` + +Docusaurus also supports MDX, which lets you add React components to your posts for interactive elements (though this is optional for beginners). + +### 5. Configuring Your Blog + +You can customize your blog by editing the `docusaurus.config.js` file in your project’s root directory. The blog settings are typically defined in the `presets` section. Here’s an example: + +```javascript +module.exports = { + // ... + presets: [ + [ + "@docusaurus/preset-classic", + { + blog: { + path: "blog", // Directory for blog posts + routeBasePath: "blog", // URL path for the blog + blogTitle: "My Blog", // Blog page title + blogDescription: "Thoughts and updates on my project", // Blog description + postsPerPage: 10, // Posts per index page + showReadingTime: true, // Show reading time for posts + }, + }, + ], + ], +}; +``` + +Key options: + +- **`path`**: Where your blog posts are stored (default: `blog`). +- **`routeBasePath`**: The URL path for your blog (e.g., `/blog`). +- **`blogTitle`**: The title shown on the blog index. +- **`blogDescription`**: A short description for SEO and feeds. +- **`postsPerPage`**: How many posts appear on each index page. +- **`showReadingTime`**: Displays estimated reading time per post. + +Check the [Docusaurus blog documentation](https://docusaurus.io/docs/blog) for more options. + +### 6. Adding the Blog to Your Site Navigation + +To help users find your blog, add a link to it in the navigation bar or footer via `docusaurus.config.js`. + +#### Navigation Bar Example + +```javascript +module.exports = { + // ... + themeConfig: { + navbar: { + items: [ + { + to: "/blog", + label: "Blog", + position: "left", + }, + ], + }, + }, +}; +``` + +#### Footer Example + +```javascript +module.exports = { + // ... + themeConfig: { + footer: { + links: [ + { + title: "Links", + items: [ + { + label: "Blog", + to: "/blog", + }, + ], + }, + ], + }, + }, +}; +``` + +This makes your blog accessible from anywhere on your site. + +### 7. Previewing Your Blog Locally + +To see your blog in action, run the development server: + +```bash +npm start +``` + +or + +```bash +yarn start +``` + +Open `http://localhost:3000/blog` in your browser to view the blog index. Click any post to see its individual page. + +### 8. Best Practices for Managing Your Blog + +As your blog grows, keep it organized with these tips: + +- **File Naming**: Stick to a consistent format like `YYYY-MM-DD-title.md` for chronological ordering. +- **Tags**: Use tags in the front matter to group related posts. Docusaurus creates tag pages (e.g., `/blog/tags/example`) automatically. +- **Content Structure**: Keep posts focused and use headings for readability. +- **Updates**: Regularly check front matter (e.g., dates, tags) to ensure accuracy. + +### 9. Example Blog Post + +Here’s a full example of a blog post file: + +```markdown +--- +title: My First Blog Post +date: 2023-10-05 +author: John Doe +tags: ["example", "blog"] +--- + +# My First Blog Post + +Hi everyone! + +## Why I’m Here + +I started this blog to: + +- Share my project journey +- Help others learn +- Get community input + +## Coming Soon + +Next, I’ll write about: + +1. Setting up tools +2. Writing clean code +3. Cool ideas to try + +Thanks for reading! +``` + +This file includes front matter and Markdown content, ready to be processed by Docusaurus. + +### 10. Next Steps and Resources + +You now have a working blog in Docusaurus! To take it further, explore: + +- Adding an RSS feed for subscribers. +- Customizing the blog’s design with CSS. +- Using MDX for advanced features. + +For more details, visit the [official Docusaurus blog documentation](https://docusaurus.io/docs/blog). diff --git a/versioned_docs/version-1.2.0/developer-guide/website/create-doc.md b/versioned_docs/version-1.2.0/developer-guide/website/create-doc.md new file mode 100644 index 00000000..0641fe38 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/website/create-doc.md @@ -0,0 +1,248 @@ +--- +title: Create a Document +sidebar_position: 1 +--- + +## Creating a Document in Docusaurus: A Beginner's Guide + +Docusaurus is a powerful tool for building documentation websites with ease. It uses Markdown files to generate static HTML pages, making it simple to create and maintain your project’s documentation. In this guide, we’ll cover everything you need to know to create a document in Docusaurus, from understanding the folder structure to configuring the sidebar navigation. + +### 1. Understanding the Docusaurus Folder Structure + +When you set up a Docusaurus project, it creates a specific folder structure to organize your site. The key folders and files related to documentation are: + +- **`docs/`**: This is where all your documentation files are stored. Each file in this folder is a Markdown file (with a `.md` or `.mdx` extension) that will be converted into a page on your documentation site. + +- **`docusaurus.config.js`**: This is the main configuration file for your Docusaurus site. It controls settings like the site title, navigation, and more. + +- **`sidebars.js`** (optional): This file allows you to manually configure the sidebar navigation for your documentation. + +- **`static/`**: This folder holds static assets like images, which can be referenced in your documentation. + +For example, a typical Docusaurus project might look like this: + +```text +my-docusaurus-site/ +├── docs/ +│ ├── intro.md +│ └── getting-started.md +├── src/ +│ └── pages/ +├── static/ +│ └── img/ +├── docusaurus.config.js +├── package.json +└── sidebars.js +``` + +In this structure, the `docs/` folder is the central location for all documentation files. This is where you’ll create and store your documents. + +### 2. Parameters at the Start of the Docs (Front Matter) + +In Docusaurus, each Markdown file can have an optional **front matter** section at the top. The front matter is written in YAML format and is enclosed between triple dashes (`---`). It provides metadata about the document, allowing you to customize its behavior and appearance. Common parameters (fields) in the front matter include: + +- **`id`**: A unique identifier for the document. If not specified, it defaults to the file name without the extension (e.g., `my-doc` for `my-doc.md`). +- **`title`**: The title of the document, displayed in the sidebar and page header. If omitted, Docusaurus uses the first heading in the file. +- **`slug`**: A custom URL path for the document (e.g., `/my-custom-url`). +- **`tags`**: Keywords for categorizing the document. + +Here’s an example of a front matter: + +```yaml +--- +id: my-doc +title: My Document +slug: /my-custom-url +tags: + - example + - documentation +--- +``` + +This front matter tells Docusaurus: + +- The document’s unique ID is `my-doc`. +- The title is “My Document”. +- The URL path is `/my-custom-url` instead of the default `/docs/my-doc`. +- It’s tagged with “example” and “documentation”. + +Front matter is optional, but it’s highly recommended for better control over your documents. + +### 3. How Folder Structure Affects Paths and Sidebar Navigation + +The folder structure within the `docs/` directory determines both the URL paths of your documents and the sidebar navigation. + +- **URL Paths**: By default, the folder structure becomes part of the document’s URL. For example: + + - `docs/intro.md` → `/docs/intro` + - `docs/architecture/overview.md` → `/docs/architecture/overview` + You can override this with the `slug` parameter in the front matter. + +- **Sidebar Navigation**: Docusaurus can automatically generate a sidebar based on your folder structure. Each subfolder in `docs/` becomes a category in the sidebar, and the files within that folder become links under that category. For example: + + ```text + docs/ + ├── intro.md + └── architecture/ + ├── overview.md + └── components.md + ``` + + This structure might produce a sidebar like: + + - Intro + - Architecture + - Overview + - Components + + The folder name (e.g., `architecture`) doesn’t automatically become the category name unless configured. You can customize this behavior using sidebar configuration files. + +#### The `_category_.json` File + +Inside a subfolder, you can add a file named `_category_.json` to configure how that folder appears in the sidebar. This file defines properties for the category. Here’s an example from the query: + +```json +{ + "label": "Architecture", + "position": 3, + "link": { + "type": "generated-index" + } +} +``` + +- **`label`**: The name displayed for the category in the sidebar (e.g., “Architecture”). +- **`position`**: The order of this category in the sidebar (e.g., 3 means it’s the third item). +- **`link`**: Defines what happens when the category is clicked. The value `"type": "generated-index"` tells Docusaurus to create an automatically generated index page for this category, listing all documents inside the folder (e.g., `overview.md` and `components.md`). + +This file gives you fine-grained control over the sidebar for that specific folder. + +### 4. Step-by-Step Process for Creating a Document (Beginner-Friendly) + +If you’re new to Docusaurus, follow these steps to create your first document: + +1. **Set Up Docusaurus**: + + - Install Docusaurus by running this command in your terminal: + + ```bash + npx create-docusaurus@latest my-site classic + ``` + + - This creates a new Docusaurus site in the `my-site` folder using the classic template. + - Navigate to your project folder: + + ```bash + cd my-site + ``` + +2. **Go to the Docs Folder**: + + - Open the `docs/` folder in your project directory (e.g., `my-site/docs/`). + +3. **Create a Markdown File**: + + - Create a new file, e.g., `my-doc.md`, using a text editor. + +4. **Add Front Matter (Optional)**: + + - At the top of the file, add metadata like this: + + ```yaml + --- + id: my-doc + title: My Document + --- + ``` + +5. **Write Your Content**: + + - Below the front matter, write your documentation using Markdown. For example: + + ```markdown + # My Document + + Welcome to my first Docusaurus document! + + ## Features + + - Easy to use + - Highly customizable + ``` + +6. **Organize with Folders (Optional)**: + + - To group related documents, create a subfolder (e.g., `docs/features/`) and move or create files inside it (e.g., `features/my-doc.md`). + +7. **Configure the Sidebar (Optional)**: + + - For automatic sidebar generation, Docusaurus will use your folder structure. + - To customize a category, add a `_category_.json` file in the subfolder. For example, in `docs/features/`: + + ```json + { + "label": "Features", + "position": 2, + "link": { + "type": "generated-index" + } + } + ``` + + - Alternatively, edit `sidebars.js` in the root directory for manual sidebar configuration. + +8. **Preview Your Site**: + - Start the development server by running: + + ```bash + npm start + ``` + + or + + ```bash + yarn start + ``` + + - Open your browser and go to `http://localhost:3000` to see your site. + - Check that your new document appears and the sidebar reflects your structure. + +### 5. Example `.md` File + +Here’s a complete example of a Markdown file you might create: + +```markdown +--- +id: architecture-overview +title: Architecture Overview +slug: /architecture +tags: + - architecture + - overview +--- + +# Architecture Overview + +This document provides an overview of the system's architecture. + +## Components + +- **Frontend**: Built with React. +- **Backend**: Powered by Node.js. + +## Design Principles + +- Modularity +- Scalability +``` + +- The front matter sets the ID, title, custom URL, and tags. +- The content uses Markdown for structure and readability. + +### 6. Additional Resources + +For more details on creating and customizing documents in Docusaurus, visit the official documentation: + +- [https://docusaurus.io/docs/create-doc](https://docusaurus.io/docs/create-doc) + +This guide covers the essentials, but Docusaurus offers advanced features like versioning and multi-language support. As you grow comfortable, explore these to enhance your documentation site. diff --git a/versioned_docs/version-1.2.0/developer-guide/website/versioning-doc.md b/versioned_docs/version-1.2.0/developer-guide/website/versioning-doc.md new file mode 100644 index 00000000..038121a5 --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/website/versioning-doc.md @@ -0,0 +1,361 @@ +--- +title: Version management +sidebar_position: 2 +--- + +# Versioning Documentation in Docusaurus: A Comprehensive Guide + +Docusaurus offers robust built-in support for versioning documentation, a critical feature for projects that evolve over time. Versioning allows you to maintain multiple versions of your documentation, ensuring users can access information relevant to the specific version of your software they are using. This comprehensive document will walk you through the process of setting up, managing, and optimizing versioned documentation in Docusaurus. + +--- + +## 1. Understanding Versioning in Docusaurus + +Docusaurus provides a straightforward system for versioning documentation: + +- **Current Version**: This is the latest, actively maintained version of your documentation, stored in the `docs/` folder. It typically represents the "Next" version or the most recent unreleased changes. +- **Versioned Docs**: These are snapshots of your documentation at specific points in time, usually tied to software releases. They are stored in folders named `versioned_docs/version-/`, such as `versioned_docs/version-1.0/` for version 1.0. + +For example: + +```text +// Project directory structure with versioning +my-docusaurus-project/ +├── docs/ # Current version documentation +├── versioned_docs/ # All versioned documentation +│ ├── version-1.0/ # Version 1.0 documentation +│ └── version-1.1/ # Version 1.1 documentation +├── versioned_sidebars/ # Sidebars for each version +│ ├── version-1.0-sidebars.json +│ └── version-1.1-sidebars.json +└── versions.json # List of all available versions +``` + +Each versioned set of documentation is a complete copy of the `docs/` folder at the time the version was created. + +--- + +## 2. Setting Up Versioning + +To begin versioning your documentation in Docusaurus, follow these steps: + +### Step 1: Create Your First Version + +When you're ready to release a new version of your software, create a versioned snapshot of your current documentation: + +- Run the following command in your terminal: + +```bash +# File: terminal command +npm run docusaurus docs:version +``` + +or + +```bash +# File: terminal command +yarn docusaurus docs:version +``` + +Replace `` with your desired version number, e.g., `1.0`. + +- **What Happens**: + - Docusaurus duplicates the entire `docs/` folder into `versioned_docs/version-1.0/`. + - It updates the `versions.json` file, which tracks all versioned documentation. + +Example `versions.json` after creating version 1.0: + +```json +// File: versions.json +[ + "1.0" +] +``` + +### Step 2: Customize Version Labels + +By default, the version number (e.g., "1.0") appears in the sidebar and version selector. You can customize these labels in `docusaurus.config.js`: + +```javascript +// File: docusaurus.config.js +module.exports = { + // ... other configuration + themeConfig: { + // ... other theme configuration + docs: { + sidebar: { + versionLabels: { + '1.0': 'Version 1.0 (Legacy)', + '1.1': 'Version 1.1', + 'current': 'Next (Unreleased)' + }, + }, + }, + }, +}; +``` + +--- + +## 3. Managing Versioned Documentation + +Once versioning is set up, you can manage your documentation as follows: + +### Updating Documentation + +- **Current Version**: Edit files in the `docs/` folder to reflect the latest changes and features. +- **Versioned Docs**: To update a specific version (e.g., for corrections or clarifications), modify files in `versioned_docs/version-/`. + +**Note**: Limit changes to versioned docs to minor fixes. Major updates should go into the current version (`docs/`). + +### Adding New Versions + +When releasing a new software version: + +```bash +# File: terminal command +# 1. Update docs/ folder with latest content +# 2. Run the versioning command +npm run docusaurus docs:version 2.0 +``` + +This creates a new snapshot in `versioned_docs/version-2.0/` and updates `versions.json`: + +```json +// File: versions.json (after adding version 2.0) +[ + "2.0", + "1.0" +] +``` + +### Removing Versions + +To delete a version: + +```bash +# File: terminal command +# 1. Remove the version folder +rm -rf versioned_docs/version-1.0 +rm -rf versioned_sidebars/version-1.0-sidebars.json + +# 2. Update versions.json manually +``` + +Edit `versions.json` to remove the version: + +```json +// File: versions.json (after removing version 1.0) +[ + "2.0" +] +``` + +--- + +## 4. Configuring the Sidebar for Versioned Docs + +Docusaurus handles sidebars for each version automatically, but you can customize them if needed. + +### Automatic Sidebar Generation + +When you create a version, Docusaurus automatically creates a sidebar configuration: + +```json +// File: versioned_sidebars/version-1.0-sidebars.json (automatically generated) +{ + "version-1.0/docs": [ + { + "type": "category", + "label": "Getting Started", + "items": [ + { + "type": "doc", + "id": "version-1.0/intro" + }, + { + "type": "doc", + "id": "version-1.0/installation" + } + ] + } + ] +} +``` + +### Manual Sidebar Configuration + +For more control, you can modify the versioned sidebar file directly: + +```javascript +// File: versioned_sidebars/version-1.0-sidebars.json (customized) +{ + "version-1.0/docs": [ + { + "type": "category", + "label": "Getting Started", + "items": [ + { + "type": "doc", + "id": "version-1.0/intro" + }, + { + "type": "doc", + "id": "version-1.0/installation" + } + ] + }, + { + "type": "category", + "label": "Advanced Topics", + "items": [ + { + "type": "doc", + "id": "version-1.0/advanced/configuration" + } + ] + } + ] +} +``` + +--- + +## 5. Linking to Versioned Docs + +### Version Dropdown Component + +Docusaurus adds a version selector dropdown to your site navigation: + +```jsx +// File: src/theme/Navbar.js (automatically handled by Docusaurus) +import React from 'react'; +import VersionsDropdown from '@theme/VersionsDropdown'; + +function Navbar() { + return ( + + ); +} +``` + +### Creating Custom Links to Specific Versions + +In your documentation, you can link to specific versions: + +```markdown + + +Check our [installation guide for v1.0](/docs/1.0/installation) or the [latest installation guide](/docs/installation). +``` + +--- + +## 6. Best Practices for Versioning + +- **Version Naming**: Use semantic versioning (e.g., 1.0, 1.1, 2.0) for clarity. + + ```text + // Recommended version naming + 1.0, 1.1, 2.0 // ✓ Semantic versioning + + // Not recommended + stable, beta, old // ✗ Ambiguous naming + ``` + +- **Configuration Example** for managing version labels and visibility: + + ```javascript + // File: docusaurus.config.js + module.exports = { + // ... other configuration + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + // ... other docs configuration + lastVersion: 'current', + versions: { + current: { + label: 'Next', + path: 'next', + }, + '2.0': { + label: '2.0', + path: '2.0', + }, + '1.0': { + label: '1.0 (Legacy)', + path: '1.0', + banner: 'unmaintained', // Adds a banner indicating this version is no longer maintained + }, + }, + }, + }, + ], + ], + }; + ``` + +--- + +## 7. Example Scenario + +Let's walk through versioning for a software project with two releases: 1.0 and 2.0. + +```bash +# File: terminal commands for versioning workflow +# Initial setup - create version 1.0 +npm run docusaurus docs:version 1.0 + +# Result: +# - versioned_docs/version-1.0/ contains a snapshot of docs/ +# - versioned_sidebars/version-1.0-sidebars.json is created +# - versions.json now includes "1.0" + +# Later - update docs/ with changes for version 2.0 and create version 2.0 +npm run docusaurus docs:version 2.0 + +# Result: +# - versioned_docs/version-2.0/ is created +# - versioned_sidebars/version-2.0-sidebars.json is created +# - versions.json now includes "2.0" and "1.0" +# - docs/ becomes the "Next" version +``` + +Final project structure: + +```text +# File: Project structure after versioning +my-docusaurus-project/ +├── docs/ # Current "Next" version +├── versioned_docs/ +│ ├── version-2.0/ # Version 2.0 documentation +│ └── version-1.0/ # Version 1.0 documentation +├── versioned_sidebars/ +│ ├── version-2.0-sidebars.json +│ └── version-1.0-sidebars.json +└── versions.json # ["2.0", "1.0"] +``` + +The result is a site where users can easily navigate between versions through the dropdown menu: + +- **Next**: Latest unreleased changes +- **2.0**: Documentation for version 2.0 +- **1.0 (Legacy)**: Documentation for version 1.0 + +--- + +## 8. Additional Resources + +For more in-depth information, refer to the official Docusaurus documentation: + +- [https://docusaurus.io/docs/versioning](https://docusaurus.io/docs/versioning) + +--- + +This guide provides everything you need to create and manage versioned documentation in Docusaurus. By following these steps, you can ensure your users have access to the right documentation for their software version. Happy documenting! diff --git a/versioned_docs/version-1.2.0/developer-guide/workflow-automation-guide.md b/versioned_docs/version-1.2.0/developer-guide/workflow-automation-guide.md new file mode 100644 index 00000000..70ef51fb --- /dev/null +++ b/versioned_docs/version-1.2.0/developer-guide/workflow-automation-guide.md @@ -0,0 +1,68 @@ +--- +sidebar_position: 3 +title: Automation Workflows +--- + +# Project Documentation: Automation Workflows + +This document outlines the automated workflows for the Kmesh project, designed to enhance documentation quality and streamline versioning. + +## 1. kmeshctl Sync Workflow + +**Purpose:** Automatically sync the kmeshctl CLI documentation from the kmesh repository to the kmesh-website repository via a Pull Request (PR). + +**Workflow Trigger:** A push to the main branch of the kmesh repository, specifically when changes are made to the `docs/ctl/` directory. + +### Steps + +1. **Checkout Repositories:** The workflow checks out both the kmesh-website and kmesh repositories. +2. **Sync with rsync:** Uses the rsync command to synchronize the `docs/ctl/` directory from kmesh into the docs/kmeshctl/ directory of kmesh-website. The --delete flag ensures that deleted files are also removed. +3. **Create Pull Request:** If changes are detected, the workflow commits them and uses the `peter-evans/create-pull-request` action to create a PR in the kmesh-website repository. The branch name includes a timestamp to ensure uniqueness and prevent conflicts. + +### Maintenance Notes + +- **Secrets:** The `WEBSITE_PAT` secret must have write access to both the `kmesh-net/kmesh` and kmesh-net/website repositories. +- **Path Changes:** If the source or target directory paths change, update the `KMESH_CTL_DIR` and `WEBSITE_KMESHCTL_DIR` variables in the workflow. + +## 2. Docusaurus Versioning and i18n (Chinese) Handling + +The Docusaurus versioning system is designed to create new versions based on the content of the source docs/ directory. When the docusaurus docs:version command is executed, it automatically generates a new versioned folder (e.g., `versioned_docs/version-X.Y.Z/`) containing all the English documentation. + +### Chinese Documentation (i18n) Versioning + +- The Docusaurus versioning command does not automatically create a corresponding versioned folder for the Chinese translations located in `i18n/zh/docusaurus-plugin-content-docs/.` +- As a result, when a new version is created, there is no `i18n/zh/docusaurus-plugin-content-docs/version-X.Y.Z/` folder. +- This causes a "Page Not Found" error for users who have selected the Chinese language and navigate to the new version. + +### Solution: Custom 404 Page + +- To provide a seamless user experience, a custom 404 page has been implemented. +- When a Chinese user encounters a missing page for a new version, they are presented with a helpful error page. +- This page includes a prominent button that allows the user to easily redirect to the English version of the requested documentation or return to the homepage. +- This approach ensures that users always have access to the information they need, even if the Chinese translation for the latest version is not yet available. + +This solution balances the need for up-to-date documentation with the practicalities of a multilingual site, where translation efforts may lag behind the release of new English content. + +### Maintenance Notes + +- This workflow relies on the `GITHUB_TOKEN` for PR creation. +- Ensure the `npm install` command is used, as a `package-lock.json` file is not available. + +## 3. Chinese Grammar Check Workflow + +**Purpose:** Automatically check the grammar and spelling of Chinese documentation. + +**Workflow Trigger:** A push or pull request to the main branch, specifically when changes are made to files in the `docs/cn/zh/` directory. + +### Steps + +- **Checkout and Setup:** The workflow checks out the code and sets up a Python environment. +- **Install Dependencies:** Installs the language-tool-python package. +- **Run Grammar Check:** Uses the LanguageTool library to scan only the .md files within the `docs/cn/zh/` directory and its subdirectories for Chinese (zh-CN) content. +- **Report Issues:** The script provides detailed, color-coded output for any issues found, including the file, line number, error type (spelling, grammar, style), context, and suggestions. It also creates GitHub warning annotations. + +### Maintenance Notes + +- The workflow is robust and includes retries for initializing the LanguageTool service. +- It handles encoding errors gracefully. +- The output is designed to be highly readable for developers, classifying errors and providing actionable feedback. diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl.md new file mode 100644 index 00000000..2a0c1ead --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl.md @@ -0,0 +1,19 @@ +## kmeshctl + +Kmesh command line tools to operate and debug Kmesh + +### Options + +```bash + -h, --help help for kmeshctl +``` + +### SEE ALSO + +* [kmeshctl authz](kmeshctl_authz.md) - Manage xdp authz eBPF program for Kmesh's authz offloading +* [kmeshctl dump](kmeshctl_dump.md) - Dump config of kernel-native or dual-engine mode +* [kmeshctl log](kmeshctl_log.md) - Get or set kmesh-daemon's logger level +* [kmeshctl monitoring](kmeshctl_monitoring.md) - Control Kmesh's monitoring to be turned on as needed +* [kmeshctl secret](kmeshctl_secret.md) - Use secrets to manage secret configuration data for IPsec +* [kmeshctl version](kmeshctl_version.md) - Prints out build version info +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_accesslog.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_accesslog.md new file mode 100644 index 00000000..85122d75 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_accesslog.md @@ -0,0 +1,27 @@ +## kmeshctl accesslog + +Enable or disable Kmesh's accesslog + +```bash +kmeshctl accesslog [flags] +``` + +### Examples + +```bash +# Enable Kmesh's accesslog: +kmeshctl accesslog enable + +# Disable Kmesh's accesslog: +kmeshctl accesslog disable +``` + +### Options + +```bash + -h, --help help for accesslog +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz.md new file mode 100644 index 00000000..f4a13364 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz.md @@ -0,0 +1,16 @@ +## kmeshctl authz + +Manage xdp authz eBPF program for Kmesh's authz offloading + +### Options + +```bash + -h, --help help for authz +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh +* [kmeshctl authz disable](kmeshctl_authz_disable.md) - Disable xdp authz eBPF program for Kmesh's authz offloading +* [kmeshctl authz enable](kmeshctl_authz_enable.md) - Enable xdp authz eBPF program for Kmesh's authz offloading +* [kmeshctl authz status](kmeshctl_authz_status.md) - Display the current authorization status diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_disable.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_disable.md new file mode 100644 index 00000000..b9a48540 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_disable.md @@ -0,0 +1,24 @@ +## kmeshctl authz disable + +Disable xdp authz eBPF program for Kmesh's authz offloading + +```bash +kmeshctl authz disable [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz disable +kmeshctl authz disable pod1 pod2 +``` + +### Options + +```bash + -h, --help help for disable +``` + +### SEE ALSO + +* [kmeshctl authz](kmeshctl_authz.md) - Manage xdp authz eBPF program for Kmesh's authz offloading diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_enable.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_enable.md new file mode 100644 index 00000000..79e95fa4 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_enable.md @@ -0,0 +1,24 @@ +## kmeshctl authz enable + +Enable xdp authz eBPF program for Kmesh's authz offloading + +```bash +kmeshctl authz enable [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz enable +kmeshctl authz enable pod1 pod2 +``` + +### Options + +```bash + -h, --help help for enable +``` + +### SEE ALSO + +* [kmeshctl authz](kmeshctl_authz.md) - Manage xdp authz eBPF program for Kmesh's authz offloading diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_status.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_status.md new file mode 100644 index 00000000..b4dbdbef --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_authz_status.md @@ -0,0 +1,24 @@ +## kmeshctl authz status + +Display the current authorization status + +```bash +kmeshctl authz status [podNames...] [flags] +``` + +### Examples + +```bash +kmeshctl authz status +kmeshctl authz status pod1 pod2 +``` + +### Options + +```bash + -h, --help help for status +``` + +### SEE ALSO + +* [kmeshctl authz](kmeshctl_authz.md) - Manage xdp authz eBPF program for Kmesh's authz offloading diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_dump.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_dump.md new file mode 100644 index 00000000..eed76b69 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_dump.md @@ -0,0 +1,27 @@ +## kmeshctl dump + +Dump config of kernel-native or dual-engine mode + +```bash +kmeshctl dump [flags] +``` + +### Examples + +```bash +# Kernel Native mode: +kmeshctl dump kernel-native + +# Dual Engine mode: +kmeshctl dump dual-engine +``` + +### Options + +```bash + -h, --help help for dump +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_log.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_log.md new file mode 100644 index 00000000..8ab262b8 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_log.md @@ -0,0 +1,31 @@ +## kmeshctl log + +Get or set kmesh-daemon's logger level + +```bash +kmeshctl log [flags] +``` + +### Examples + +```bash +# Set default logger's level as "debug": +kmeshctl log --set default:debug + +# Get all loggers' name +kmeshctl log + +# Get default logger's level: +kmeshctl log default +``` + +### Options + +```bash + -h, --help help for log + --set string Set the logger level (e.g., default:debug) +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_monitoring.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_monitoring.md new file mode 100644 index 00000000..5cec0dc4 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_monitoring.md @@ -0,0 +1,50 @@ +## kmeshctl monitoring + +Control Kmesh's monitoring to be turned on as needed + +```bash +kmeshctl monitoring [flags] +``` + +### Examples + +```bash +# Enable/Disable Kmesh's accesslog: +kmeshctl monitoring --accesslog enable/disable + +# Enable/Disable services' metrics and accesslog generated from bpf: +kmeshctl monitoring --all enable/disable + +# Enable/Disable workload granularity metrics: +kmeshctl monitoring --workloadMetrics enable/disable + +# Enable/Disable connection granularity metrics: +kmeshctl monitoring --connectionMetrics enable/disable + +# If you want to change the monitoring functionality of all kmesh daemons in the cluster +# Enable/Disable Kmesh's accesslog in each node: +kmeshctl monitoring --accesslog enable/disable + +# Enable/Disable workload granularity metrics in each node: +kmeshctl monitoring --workloadMetrics enable/disable + +# Enable/Disable connection granularity metrics in each node: +kmeshctl monitoring --connectionMetrics enable/disable + +#Enable/Disable services', workloads' and 'connections' metrics and accesslog generated from bpf in each node: +kmeshctl monitoring --all enable/disable +``` + +### Options + +```bash + --accesslog string Control accesslog enable or disable + --all string Control accesslog and services' and workloads' metrics enable or disable together + --connectionMetrics string Control connection granularity metrics enable or disable + -h, --help help for monitoring + --workloadMetrics string Control workload granularity metrics enable or disable +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret.md new file mode 100644 index 00000000..01cdbdce --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret.md @@ -0,0 +1,30 @@ +## kmeshctl secret + +Use secrets to manage secret configuration data for IPsec + +```bash +kmeshctl secret [flags] +``` + +### Examples + +```bash +# Use kmeshctl secret to manage secret configuration data for IPsec: +kmeshctl secret create or kmeshctl secret create --key=$(echo -n "{36-character user-defined key here}" | xxd -p -c 64) +kmeshctl secret get +kmeshctl secret delete + +``` + +### Options + +```bash + -h, --help help for secret +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh +* [kmeshctl secret create](kmeshctl_secret_create.md) - Generate IPsec key and configuration by kmeshctl +* [kmeshctl secret delete](kmeshctl_secret_delete.md) - Delete IPsec key and configuration by kmeshctl +* [kmeshctl secret get](kmeshctl_secret_get.md) - Get IPsec key and configuration by kmeshctl diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_create.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_create.md new file mode 100644 index 00000000..63d82d95 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_create.md @@ -0,0 +1,27 @@ +## kmeshctl secret create + +Generate IPsec key and configuration by kmeshctl + +```bash +kmeshctl secret create [flags] +``` + +### Examples + +```bash +# Generate IPsec configuration with random IPsec key: +kmeshctl secret create +# Generate IPsec configuration with user-defined key: +kmeshctl secret create --key=$(echo -n "{36-character user-defined key here}" | xxd -p -c 64) +``` + +### Options + +```bash + -h, --help help for create + -k, --key string key of the encryption +``` + +### SEE ALSO + +* [kmeshctl secret](kmeshctl_secret.md) - Use secrets to manage secret configuration data for IPsec diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_delete.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_delete.md new file mode 100644 index 00000000..90790edd --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_delete.md @@ -0,0 +1,23 @@ +## kmeshctl secret delete + +Delete IPsec key and configuration by kmeshctl + +```bash +kmeshctl secret delete [flags] +``` + +### Examples + +```bash +kmeshctl secret delete +``` + +### Options + +```bash + -h, --help help for delete +``` + +### SEE ALSO + +* [kmeshctl secret](kmeshctl_secret.md) - Use secrets to manage secret configuration data for IPsec diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_get.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_get.md new file mode 100644 index 00000000..5c792c9c --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_secret_get.md @@ -0,0 +1,24 @@ +## kmeshctl secret get + +Get IPsec key and configuration by kmeshctl + +```bash +kmeshctl secret get [flags] +``` + +### Examples + +```bash +# Get IPsec key and configuration by kmeshctl. The results will be displayed in JSON format. +kmeshctl secret get +``` + +### Options + +```bash + -h, --help help for get +``` + +### SEE ALSO + +* [kmeshctl secret](kmeshctl_secret.md) - Use secrets to manage secret configuration data for IPsec diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_version.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_version.md new file mode 100644 index 00000000..388a9429 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_version.md @@ -0,0 +1,27 @@ +## kmeshctl version + +Prints out build version info + +```bash +kmeshctl version [flags] +``` + +### Examples + +```bash +# Show version of all kmesh components +kmeshctl version + +# Show version info of a specific kmesh daemon +kmeshctl version +``` + +### Options + +```bash + -h, --help help for version +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint.md new file mode 100644 index 00000000..6a7dc17c --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint.md @@ -0,0 +1,42 @@ +## kmeshctl waypoint + +Manage waypoint configuration + +### Synopsis + +A group of commands used to manage waypoint configuration + +```bash +kmeshctl waypoint [flags] +``` + +### Examples + +```bash + # Apply a waypoint to the current namespace + kmeshctl waypoint apply + + # Generate a waypoint as yaml + kmeshctl waypoint generate --namespace default + + # List all waypoints in a specific namespace + kmeshctl waypoint list --namespace default +``` + +### Options + +```bash + -h, --help help for waypoint + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl](kmeshctl.md) - Kmesh command line tools to operate and debug Kmesh +* [kmeshctl waypoint apply](kmeshctl_waypoint_apply.md) - Apply a waypoint configuration +* [kmeshctl waypoint delete](kmeshctl_waypoint_delete.md) - Delete a waypoint configuration +* [kmeshctl waypoint generate](kmeshctl_waypoint_generate.md) - Generate a waypoint configuration +* [kmeshctl waypoint list](kmeshctl_waypoint_list.md) - List managed waypoint configurations +* [kmeshctl waypoint status](kmeshctl_waypoint_status.md) - Show the status of waypoints in a namespace diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_apply.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_apply.md new file mode 100644 index 00000000..75244189 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_apply.md @@ -0,0 +1,47 @@ +## kmeshctl waypoint apply + +Apply a waypoint configuration + +### Synopsis + +Apply a waypoint configuration to the cluster + +```bash +kmeshctl waypoint apply [flags] +``` + +### Examples + +```bash + # Apply a waypoint to the current namespace + kmeshctl waypoint apply + + # Apply a waypoint to a specific namespace and wait for it to be ready + kmeshctl waypoint apply --namespace default --wait + + # Apply a waypoint to a specific pod + kmeshctl waypoint apply -n default --name reviews-v2-pod-waypoint --for workload +``` + +### Options + +```bash + --enroll-namespace If set, the namespace will be labeled with the waypoint name + --for string Specify the traffic type [all none service workload] for the waypoint + -h, --help help for apply + --overwrite Overwrite the existing Waypoint used by the namespace + -r, --revision string The revision to label the waypoint with + -w, --wait Wait for the waypoint to be ready +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_delete.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_delete.md new file mode 100644 index 00000000..420ac3bc --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_delete.md @@ -0,0 +1,46 @@ +## kmeshctl waypoint delete + +Delete a waypoint configuration + +### Synopsis + +Delete a waypoint configuration from the cluster + +```bash +kmeshctl waypoint delete [flags] +``` + +### Examples + +```bash + # Delete a waypoint from the default namespace + kmeshctl waypoint delete + + # Delete a waypoint by name, which can obtain from kmeshctl waypoint list + kmeshctl waypoint delete waypoint-name --namespace default + + # Delete several waypoints by name + kmeshctl waypoint delete waypoint-name1 waypoint-name2 --namespace default + + # Delete all waypoints in a specific namespace + kmeshctl waypoint delete --all --namespace default +``` + +### Options + +```bash + --all Delete all waypoints in the namespace + -h, --help help for delete +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_generate.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_generate.md new file mode 100644 index 00000000..2029133f --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_generate.md @@ -0,0 +1,41 @@ +## kmeshctl waypoint generate + +Generate a waypoint configuration + +### Synopsis + +Generate a waypoint configuration as YAML + +```bash +kmeshctl waypoint generate [flags] +``` + +### Examples + +```bash + # Generate a waypoint as yaml + kmeshctl waypoint generate --namespace default + + # Generate a waypoint that can process traffic for service in default namespace + kmeshctl waypoint generate --for service -n default +``` + +### Options + +```bash + --for string Specify the traffic type [all none service workload] for the waypoint + -h, --help help for generate + -r, --revision string The revision to label the waypoint with +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_list.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_list.md new file mode 100644 index 00000000..b96a82c0 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_list.md @@ -0,0 +1,40 @@ +## kmeshctl waypoint list + +List managed waypoint configurations + +### Synopsis + +List managed waypoint configurations in the cluster + +```bash +kmeshctl waypoint list [flags] +``` + +### Examples + +```bash + # List all waypoints in a specific namespace + kmeshctl waypoint list --namespace default + + # List all waypoints in the cluster + kmeshctl waypoint list -A +``` + +### Options + +```bash + -A, --all-namespaces List all waypoints in all namespaces + -h, --help help for list +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_status.md b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_status.md new file mode 100644 index 00000000..942423a6 --- /dev/null +++ b/versioned_docs/version-1.2.0/kmeshctl/kmeshctl_waypoint_status.md @@ -0,0 +1,39 @@ +## kmeshctl waypoint status + +Show the status of waypoints in a namespace + +### Synopsis + +Show the status of waypoints for the namespace provided or default namespace if none is provided + +```bash +kmeshctl waypoint status [flags] +``` + +### Examples + +```bash + # Show the status of the waypoint in the default namespace + kmeshctl waypoint status + + # Show the status of the waypoint in a specific namespace + kmeshctl waypoint status --namespace foo +``` + +### Options + +```bash + -h, --help help for status +``` + +### Options inherited from parent commands + +```bash + --image string image of the waypoint + --name string name of the waypoint (default "waypoint") + -n, --namespace string Kubernetes namespace +``` + +### SEE ALSO + +* [kmeshctl waypoint](kmeshctl_waypoint.md) - Manage waypoint configuration diff --git a/versioned_docs/version-1.2.0/performance/_category_.json b/versioned_docs/version-1.2.0/performance/_category_.json new file mode 100644 index 00000000..a1f7c1ae --- /dev/null +++ b/versioned_docs/version-1.2.0/performance/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Performance", + "position": 4, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/performance/images/fortio_performance_test.png b/versioned_docs/version-1.2.0/performance/images/fortio_performance_test.png new file mode 100644 index 00000000..893e4af7 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/fortio_performance_test.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/perf_network.png b/versioned_docs/version-1.2.0/performance/images/perf_network.png new file mode 100644 index 00000000..7951459c Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/perf_network.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test1.png b/versioned_docs/version-1.2.0/performance/images/resource_test1.png new file mode 100644 index 00000000..6321b3a5 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test1.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test2.png b/versioned_docs/version-1.2.0/performance/images/resource_test2.png new file mode 100644 index 00000000..c92df042 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test2.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test3.png b/versioned_docs/version-1.2.0/performance/images/resource_test3.png new file mode 100644 index 00000000..e82a8c06 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test3.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_env.png b/versioned_docs/version-1.2.0/performance/images/resource_test_env.png new file mode 100644 index 00000000..19e1bd0b Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_env.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_memory.png b/versioned_docs/version-1.2.0/performance/images/resource_test_memory.png new file mode 100644 index 00000000..b21e2c34 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_memory.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_result1.png b/versioned_docs/version-1.2.0/performance/images/resource_test_result1.png new file mode 100644 index 00000000..c103cb4d Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_result1.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_result2.png b/versioned_docs/version-1.2.0/performance/images/resource_test_result2.png new file mode 100644 index 00000000..958e1e3c Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_result2.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_result3.png b/versioned_docs/version-1.2.0/performance/images/resource_test_result3.png new file mode 100644 index 00000000..f27cdb9e Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_result3.png differ diff --git a/versioned_docs/version-1.2.0/performance/images/resource_test_result4.png b/versioned_docs/version-1.2.0/performance/images/resource_test_result4.png new file mode 100644 index 00000000..55c20067 Binary files /dev/null and b/versioned_docs/version-1.2.0/performance/images/resource_test_result4.png differ diff --git a/versioned_docs/version-1.2.0/performance/performance.md b/versioned_docs/version-1.2.0/performance/performance.md new file mode 100644 index 00000000..a78650ba --- /dev/null +++ b/versioned_docs/version-1.2.0/performance/performance.md @@ -0,0 +1,47 @@ +--- +title: Kmesh Performance +sidebar_position: 1 +--- + +## Observability Integrations + +Kmesh provides comprehensive monitoring capabilities through integration with industry-standard observability platforms: + +- **Prometheus**: Collects and stores metrics for Kmesh performance and operations +- **Grafana**: Visualizes Kmesh metrics through customizable dashboards +- **Jaeger**: Enables distributed tracing to analyze service mesh traffic patterns + +These integrations help monitor Kmesh's performance metrics, resource consumption, and traffic patterns in real-time. + +## Test Network Setup + +![Performance network diagram](./images/perf_network.png) + +## How We Test + +### Testing Tools + +Kmesh uses two main testing tools: + +- **Fortio**: A microservice load testing tool that measures: + - Latency (TP90, TP99) + - Throughput (QPS) +- **Dstat**: A system monitoring tool that tracks CPU usage during tests + +### Test Method + +Test a group of `fortio` performance data by using the number of concurrent connections as a variable parameter, and collect the CPU usage during the test. The [test script](https://github.com/kmesh-net/kmesh/tree/main/test/performance) has been archived. + +## Running the Tests + +```shell +#Preparing the test environment +[root@perf]# ./fortio_perf.sh +# Generate a CSV table of test results in the directory. +[root@perf]# ll +-rw-r--r--. 1 root root 6.1K Nov 5 17:39 fortio_perf_test.csv +``` + +## Performance Results + +![Performance test results](./images/fortio_performance_test.png) diff --git a/versioned_docs/version-1.2.0/performance/resource-consumption.md b/versioned_docs/version-1.2.0/performance/resource-consumption.md new file mode 100644 index 00000000..bb8be014 --- /dev/null +++ b/versioned_docs/version-1.2.0/performance/resource-consumption.md @@ -0,0 +1,222 @@ +--- +title: Kmesh Resource Consumption +sidebar_position: 2 +--- + +# Kmesh Resource Consumption + +## Background Information + +eBPF programs consume CPU and memory resources during execution. To better understand Kmesh's resource consumption under different workloads, we conducted several CPU and memory stress tests. These tests evaluate the limits of Kmesh's resource consumption in real-world usage scenarios. + +**Note: This documentation is based on Kmesh 0.4 kernel-native mode** + +## Environment Setup + +![Resource test environment](./images/resource_test_env.png) + +| Component | Version/Details | +| ----------------- | --------------------------------------------------------------------------------------------------------------------- | +| K8S | v1.27 | +| Kmesh | 0.4 kernel-native mode | +| Kernel | 5.10 | +| Node | 8U16G | +| Testing tool | fortio | +| Metric collection | [bpftop](https://github.com/Netflix/bpftop), [inspektor-gadget](https://github.com/inspektor-gadget/inspektor-gadget) | + +## Test Case 1: POD with CPU Limit + +### Scenario 1.1: Single App with CPU Limit + +![Resource test 1](./images/resource_test1.png) + +We set a CPU limit of 1 (1 CPU) for App A and collected the corresponding Kmesh eBPF CPU consumption. + +:::note +With the system having 8 cores and a CPU limit of 1, the POD can consume up to 12.5% of the total CPU. +::: + +**Test Procedure:** + +1. Generated load using the fortio client: + + ```bash + # !/bin/bash + + client_address=`kubectl get pod | grep fortio-client | awk {'print $1'}` + echo "$client_address" | xargs -P 0 -I {} kubectl exec -it {} -- fortio load -quiet -c 1500 -t 100s -qps 0 -keepalive=false fortio-server.default.svc.cluster.local:80 + ``` + +2. Collected CPU usage with bpftop: + + ```bash + ./bpftop + ``` + +**Test Results:** + +![Resource result 1](./images/resource_test_result1.png) + +The 12.99% shown in the figure means that 12.99% of one CPU core was consumed. + +**Conclusion:** +When App A fully utilizes one CPU core, the eBPF program consumes 1.73% of the CPU (13.9% usage of one CPU core = 1.73% of 8 CPU cores), which is less than the POD CPU limit of 12.5%. There are two possible explanations: + +- App A and Kmesh eBPF share the POD CPU limit, with Kmesh eBPF CPU being restricted by the POD CPU limit +- The eBPF CPU cost is relatively small compared to the application itself, and App A is not generating enough load to cause eBPF to exceed the CPU limit + +### Scenario 1.2: Multiple Apps with CPU Limits + +![Resource test 2](./images/resource_test2.png) + +We deployed 4 instances of App A, with a CPU limit of 250m for each instance, totaling 1 CPU for all 4 instances. + +**Test Results:** + +![Resource result 2](./images/resource_test_result2.png) + +The 13.42% shown in the figure means that 13.42% of one CPU core was consumed. + +**Conclusion:** +When App A fully utilizes one CPU, the eBPF program consumes 1.81% of the CPU, which is less than the POD CPU limit of 12.5%. + +### Scenario 1.3: Modified eBPF Code to Increase CPU Usage + +We modified the eBPF code to decrease its performance, causing it to consume more CPU, to observe if it could exceed the POD CPU limit. + +**Implementation:** +Added a for loop in the Kmesh eBPF code: + +```c +SEC("cgroup/connect4") +int cgroup_connect4_prog(struct bpf_sock_addr *ctx) +{ + struct kmesh_context kmesh_ctx = {0}; + kmesh_ctx.ctx = ctx; + kmesh_ctx.orig_dst_addr.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_ip.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_port = ctx->user_port; + + if (handle_kmesh_manage_process(&kmesh_ctx) || !is_kmesh_enabled(ctx)) { + return CGROUP_SOCK_OK; + } + + // Add for loop to increase CPU usage + int i; + for (i = 0; i < 65535; i++) { + bpf_printk("increase cpu usage"); + } + + int ret = sock4_traffic_control(ctx); + return CGROUP_SOCK_OK; +} +``` + +**Test Results:** + +![Resource result 3](./images/resource_test_result3.png) + +When App A fully utilizes one CPU, the eBPF program consumes up to 12.1% of the CPU, which is still less than the POD CPU limit of 12.5%. After multiple rounds of testing, the eBPF's CPU consumption consistently remained below the POD CPU limit. + +**Conclusion:** +Kmesh eBPF and the application share the POD CPU limit, with Kmesh eBPF CPU being constrained by the POD CPU limit. + +## Test Case 2: Scenarios without POD CPU Limits + +### Scenario 2.1: Testing eBPF CPU Consumption without Limits + +![Resource test 3](./images/resource_test3.png) + +We created 8 instances of App A with no CPU limits. We gradually increased the number of processes generating load for App A until the node's CPU usage reached 100%, then collected the CPU usage of Kmesh eBPF. + +**Test Results (8-core CPU totaling 8000m):** + +| Threads | App A CPU Usage | eBPF CPU Usage | +| ------- | --------------- | -------------- | +| 100 | 12.3% | 1% | +| 500 | 35% | 4.1% | +| 1000 | 61.7% | 8.8% | +| 3000 | 67% | 9.5% | + +With 3000 concurrent processes, the node reached 100% CPU utilization. At this point, App A consumed 67% of the CPU, while Kmesh eBPF consumed approximately 9.5%. + +**Conclusions:** + +- App A consumes significantly more CPU than eBPF, making it difficult to overload eBPF. In scenarios tested with Fortio, Kmesh eBPF consumed a maximum of 9.5% CPU. +- Further testing is needed to determine the maximum CPU consumption limit for eBPF itself. + +### Scenario 2.2: eBPF CPU Stress Test + +The [eBPF official documentation](https://ebpf-docs.dylanreimerink.nl/linux/concepts/verifier/) indicates that eBPF programs have robust security mechanisms that automatically detect infinite loops and strictly limit the number of iterations in for loops. In the current Kernel version (v5.10), eBPF programs support a maximum of 65,535 iterations in for loops. + +We added 65,535 iterations to the for loop and tested it: + +```c +SEC("cgroup/connect4") +int cgroup_connect4_prog(struct bpf_sock_addr *ctx) +{ + struct kmesh_context kmesh_ctx = {0}; + kmesh_ctx.ctx = ctx; + kmesh_ctx.orig_dst_addr.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_ip.ip4 = ctx->user_ip4; + kmesh_ctx.dnat_port = ctx->user_port; + + if (handle_kmesh_manage_process(&kmesh_ctx) || !is_kmesh_enabled(ctx)) { + return CGROUP_SOCK_OK; + } + + // Add for loop to increase CPU usage + int i; + for (i=0;i<65535;i++) { + bpf_printk("increase cpu usage"); + } + + int ret = sock4_traffic_control(ctx); + return CGROUP_SOCK_OK; +} +``` + +**Test Results:** + +![Resource result 4](./images/resource_test_result4.png) + +When the node's CPU was running at 100%, Kmesh eBPF consumed approximately 99.3% of the CPU. This stress test ran for 10 minutes, during which the kernel and services within the cluster continued to operate stably. + +**Conclusion:** +In the Kmesh eBPF component, when adding support for the maximum number of for loop iterations, eBPF can consume all available CPU resources. However, the kernel's security mechanisms ensure the stable operation of the system. + +## Kmesh eBPF Memory Limit Test + +The memory consumption of eBPF has an upper limit, as stated in the [official documentation](https://ebpf-docs.dylanreimerink.nl/linux/concepts/resource-limit/). This limit is set through the `memory.max` setting in cGroup configurations. + +However, based on the current implementation of Kmesh, memory is allocated at the start of Kmesh and does not increase during runtime. We conducted tests to verify the memory usage. + +### Test 1: Memory Usage with Varying Service Counts + +We created 1, 100, and 1000 services respectively in the cluster and recorded the eBPF memory consumption using [inspektor-gadget](https://github.com/inspektor-gadget/inspektor-gadget). + +**Monitoring Command:** + +```bash +kubectl gadget top ebpf +``` + +![Resource result memory](./images/resource_test_memory.png) + +**Test Results:** + +| Service Count | eBPF Memory Usage | +| ------------- | ----------------- | +| 1 | 23 MB | +| 100 | 23 MB | +| 1000 | 23 MB | + +**Conclusion:** +The eBPF memory consumption of Kmesh is consistently 23 MB, regardless of the number of services. + +### Test 2: Memory Usage Under Load + +We created a service (App A) in the cluster, generated load, and observed eBPF memory consumption. + +**Test Results:** +Kmesh eBPF memory consumption remained constant at 23 MB, regardless of the load. diff --git a/versioned_docs/version-1.2.0/setup/_category_.json b/versioned_docs/version-1.2.0/setup/_category_.json new file mode 100644 index 00000000..7ec8de9c --- /dev/null +++ b/versioned_docs/version-1.2.0/setup/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Setup", + "position": 2, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/setup/develop-with-kind.md b/versioned_docs/version-1.2.0/setup/develop-with-kind.md new file mode 100644 index 00000000..ec6da076 --- /dev/null +++ b/versioned_docs/version-1.2.0/setup/develop-with-kind.md @@ -0,0 +1,171 @@ +--- +title: Deploy/Develop with Kind +sidebar_position: 2 +--- + +# Deploy/Develop with Kind + +[Kind](https://github.com/kubernetes-sigs/kind) is a convenient tool for quickly deploying kubernetes cluster locally. We can use `kind` to create an `istio` cluster and deploy `kmesh`. + +## Deploy Kmesh in Kind + +Let's start from setting up the required environment. You can follow the steps below: + +### Install kind + +Installing `kind` is very simple, because it's just a binary file. You can select the correct one according to the version and the architecture in the [github releases page](https://github.com/kubernetes-sigs/kind/releases). Take `linux` + `amd64` as example: + +```shell +wget -O kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-linux-amd64 +chmod +x kind +mv kind /usr/bin/ +``` + +### Create Kubernetes cluster using kind + +You can take reference from the [istio official document](https://istio.io/latest/docs/setup/platform-setup/kind/). + +If you want to specified multiple workers or node image, you can: + +```shell +kind create cluster --image=kindest/node:v1.30.0 --config=- < **Note**: To use waypoint you need to install the Kubernetes Gateway API CRDs, which don't come installed by default on most Kubernetes clusters: + +```shell +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +### Only install Istiod + +Installing ambient mode istio by above steps will install additional istio components. + +The process of installing only `istiod` as the control plane for Kmesh is provided next. + +#### Install Istio CRDs + +```shell +helm repo add istio https://istio-release.storage.googleapis.com/charts +helm repo update +``` + +To install the chart with the release name `istio-base`: + +```shell +kubectl create namespace istio-system +helm install istio-base istio/base -n istio-system +``` + +#### Install Istiod + +To install the chart with the release name `istiod`: + +```shell +helm install istiod istio/istiod --namespace istio-system --version 1.24.0 --set pilot.env.PILOT_ENABLE_AMBIENT=true +``` + +> **Important:** Must set `pilot.env.PILOT_ENABLE_AMBIENT=true`. otherwise Kmesh will not be able to establish grpc links with istiod! If you want to use the Waypoint feature, you should use the istio version 1.23 ~ 1.25. + +After installing istiod, it's time to install Kubernetes Gateway API CRDs. + +```shell +kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl apply -f -; } +``` + +## Install Kmesh + +We offer several ways to install Kmesh: + +### Option 1: Install from OCI Registry (Recommended) + +You can install Kmesh directly from the GitHub Container Registry without cloning the repository: + +```shell +helm install kmesh oci://ghcr.io/kmesh-net/kmesh-helm --version x.y.z -n kmesh-system --create-namespace +``` + +- Replace `x.y.z` with your desired version from [kmesh-helm packages](https://github.com/orgs/kmesh-net/packages/container/package/kmesh-helm): + - For stable releases, use a version like `v1.1.0`. + - For pre-releases, use a version like `v1.1.0-alpha`. + - Omit the `--version` flag to install the latest version (not recommended for production). + +### Option 2: Install from Helm + +```shell +helm install kmesh ./deploy/charts/kmesh-helm -n kmesh-system --create-namespace +``` + +### Option 3: Install from Helm Chart Archive + +```shell +helm install kmesh ./kmesh-helm-.tgz -n kmesh-system --create-namespace +``` + +- Download the `kmesh-helm-.tgz` archive from [GitHub Releases](https://github.com/kmesh-net/kmesh/releases). Replace `` in the command above with the version you downloaded (e.g., `v1.1.0`). + +### Option 4: Install from Yaml + +```shell +kubectl create namespace kmesh-system +kubectl apply -f ./deploy/yaml/ +``` + +You can confirm the status of Kmesh with the following command: + +```shell +kubectl get pod -n kmesh-system +NAME READY STATUS RESTARTS AGE +kmesh-v2frk 1/1 Running 0 18h +``` + +View the running status of Kmesh service: + +```log +time="2024-04-25T13:17:40Z" level=info msg="bpf Start successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="controller Start successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="dump StartServer successful" subsys=manager +time="2024-04-25T13:17:40Z" level=info msg="start write CNI config\n" subsys="cni installer" +time="2024-04-25T13:17:40Z" level=info msg="kmesh cni use chained\n" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="Copied /usr/bin/kmesh-cni to /opt/cni/bin." subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="kubeconfig either does not exist or is out of date, writing a new one" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="wrote kubeconfig file /etc/cni/net.d/kmesh-cni-kubeconfig" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="cni config file: /etc/cni/net.d/10-kindnet.conflist" subsys="cni installer" +time="2024-04-25T13:17:41Z" level=info msg="command Start cni successful" subsys=manager +``` + +## Verify Installation + +After installing Kmesh, verify all components are functioning correctly: + +### 1. Verify Core Components + +Check Kmesh pod status: + +```shell +kubectl get pod -n kmesh-system +NAME READY STATUS RESTARTS AGE +kmesh-v2frk 1/1 Running 0 18h +``` + +Check Istio components: + +```shell +kubectl get pods -n istio-system +NAME READY STATUS RESTARTS AGE +istiod-5659cfbd55-9s92d 1/1 Running 0 18h +``` + +### 2. Verify Pod Integration + +Deploy a test pod and verify Kmesh annotation: + +```shell +kubectl describe po | grep Annotations +Annotations: kmesh.net/redirection: enabled +``` + +### 3. Verify Service Connectivity + +Test service access using the sleep pod: + +```shell +kubectl exec sleep-7656cf8794-xjndm -c sleep -- curl -IsS "http://httpbin:8000/status/200" +``` + +Expected response should show HTTP 200 OK status. + +### 4. Verify Kmesh Service Logs + +Check for successful initialization messages: + +```shell +kubectl logs -n kmesh-system $(kubectl get pods -n kmesh-system -o jsonpath='{.items.metadata.name}') +``` + +Look for these key messages: + +- "bpf Start successful" +- "controller Start successful" +- "dump StartServer successful" +- "command Start cni successful" + +### 5. Verify CNI Configuration + +Check CNI binary installation: + +```shell +ls -l /opt/cni/bin/kmesh-cni +``` + +Verify CNI configuration: + +```shell +cat /etc/cni/net.d/kmesh-cni-kubeconfig +``` + +## Change Kmesh Start Mode + +Kmesh supports two start up modes: `dual-engine` and `kernel-native`. + +The specific mode to be used is defined in deploy/charts/kmesh-helm/values.yaml, and we can modify the startup parameters in that file. + +```yaml +...... + containers: + kmeshDaemonArgs: "--mode=dual-engine --enable-bypass=false" +...... +``` + +We can use the following command to make the modification: + +```shell +sed -i 's/--mode=dual-engine/--mode=kernel-native/' deploy/charts/kmesh-helm/values.yaml +``` + +## Deploy the Sample Applications + +Kmesh can manage pods in a namespace with a label `istio.io/dataplane-mode=Kmesh`, and meanwhile the pod should have no `istio.io/dataplane-mode=none` label. + +```shell +# Enable Kmesh for the specified namespace +kubectl label namespace default istio.io/dataplane-mode=Kmesh +``` + +Apply the following configuration to deploy sleep and httpbin: + +```shell +kubectl apply -f ./samples/httpbin/httpbin.yaml + +kubectl apply -f ./samples/sleep/sleep.yaml +``` + +Check the applications status: + +```shell +kubectl get pod +NAME READY STATUS RESTARTS AGE +httpbin-65975d4c6f-96kgw 1/1 Running 0 3h38m +sleep-7656cf8794-8tp9n 1/1 Running 0 3h38m +``` + +You can confirm if a pod is managed by Kmesh by looking at the pod's annotation. + +```shell +kubectl describe po httpbin-65975d4c6f-96kgw | grep Annotations + +Annotations: kmesh.net/redirection: enabled +``` + +## Test Service Access + +After the applications have been manage by Kmesh, we can test that they can still communicate successfully. + +```shell +kubectl exec sleep-7656cf8794-xjndm -c sleep -- curl -IsS "http://httpbin:8000/status/200" + +HTTP/1.1 200 OK +Server: gunicorn/19.9.0 +Date: Sun, 28 Apr 2024 07:31:51 GMT +Connection: keep-alive +Content-Type: text/html; charset=utf-8 +Access-Control-Allow-Origin: * +Access-Control-Allow-Credentials: true +Content-Length: 0 +``` + +Note: 10.244.0.21 is the IP of httpbin + +## Clean Up + +If you don't want to use Kmesh to manage the application anymore, you can remove the labels from the namespace. + +```shell +kubectl label namespace default istio.io/dataplane-mode- +kubectl delete pod httpbin-65975d4c6f-96kgw sleep-7656cf8794-8tp9n +kubectl describe pod httpbin-65975d4c6f-h2r99 | grep Annotations + +Annotations: +``` + +### Delete Kmesh + +If you installed Kmesh using any of the Helm options above: + +```shell +helm uninstall kmesh -n kmesh-system +kubectl delete ns kmesh-system +``` + +If you installed Kmesh using yaml: + +```shell +kubectl delete -f ./deploy/yaml/ +``` + +To remove the sleep and httpbin applications: + +```shell +kubectl delete -f samples/httpbin/httpbin.yaml +kubectl delete -f samples/sleep/sleep.yaml +``` + +If you installed the Gateway API CRDs, remove them: + +```shell +kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=444631bfe06f3bcca5d0eadf1857eac1d369421d" | kubectl delete -f - +``` diff --git a/versioned_docs/version-1.2.0/setup/troubleshooting.md b/versioned_docs/version-1.2.0/setup/troubleshooting.md new file mode 100644 index 00000000..677219dd --- /dev/null +++ b/versioned_docs/version-1.2.0/setup/troubleshooting.md @@ -0,0 +1,174 @@ +--- +title: Installation Troubleshooting Guide +sidebar_position: 4 +--- + +## Common Installation Issues + +### Port Conflicts + +When deploying Kmesh, you might encounter port conflicts, particularly with port 15006 which is used by default. + +| Error Code | Description | Impact | Solution | +| --------------- | ------------------------- | ------------------------ | --------------------------------- | +| ERR_PORT_IN_USE | Port 15006 already in use | Prevents Kmesh startup | Change port or free existing port | +| MISSING_DEP | Missing libbpf dependency | BPF features unavailable | Install libbpf ≥0.8 | +| CNI_CONFLICT | CNI plugin conflicts | Network setup fails | Verify CNI configuration | + +## Detailed Solutions + +### Port Conflict Resolution + +If you encounter **ERR_PORT_IN_USE**, follow these steps: + +1. **Diagnose the Conflict**: + + ```shell + # Check what's using port 15006 + sudo lsof -i :15006 + + # For systemd services + sudo ss -lptn 'sport = :15006' + ``` + +2. **Resolution Options**: + + a. Change Kmesh Port: + + ```yaml + # kmesh-config.yaml + apiVersion: kmesh.net/v1 + kind: KmeshConfig + metadata: + name: kmesh-config + namespace: kmesh-system + spec: + port: 15007 + logLevel: info + enableMetrics: true + ``` + + b. Free Existing Port: + + ```shell + # Identify and stop conflicting process + sudo fuser -k 15006/tcp + ``` + +### Dependency Management + +#### Install libbpf + +Required for BPF functionality: + +```bash +# Ubuntu/Debian systems +sudo apt-get update +sudo apt-get install -y \ + libbpf-dev \ + linux-headers-$(uname -r) + +# Verify installation +dpkg -l | grep libbpf + +# CentOS/RHEL systems +sudo yum install -y libbpf-devel kernel-devel +``` + +## Runtime Verification + +### System Requirements Check + +```shell +# Kernel version check +uname -r # Should be ≥ 5.10.0 for full features + +# BPF verification +sudo bpftool prog list + +# Resource limits +ulimit -n # Should be ≥ 65535 +``` + +### Pod Management + +Verify Kmesh integration: + +```shell +# Check pod annotations +kubectl get pod -o jsonpath='{.metadata.annotations}' | jq + +# Enable Kmesh management +kubectl label namespace default istio.io/dataplane-mode=Kmesh --overwrite + +# Verify Kmesh status +kubectl -n kmesh-system get pods -l app=kmesh +``` + +### Logging and Debugging + +#### Enhanced Logging + +```shell +# Enable debug logging +kmeshctl accesslog --set default:debug + +# Monitor BPF events (kernel ≥ 5.10.0) +kubectl exec -n kmesh-system -- kmesh-daemon log --set bpf:debug + +# Collect all logs +kubectl logs -n kmesh-system -l app=kmesh --all-containers --tail=1000 > kmesh-debug.log +``` + +## Clean-up Procedures + +### Cleanup + +Remove Kmesh and its configurations: + +```shell +# Using Helm +helm uninstall kmesh -n kmesh-system + +# Using kubectl +kubectl delete namespace kmesh-system +kubectl delete -f kmesh-config.yaml + +# Clean CNI configurations +sudo rm -f /etc/cni/net.d/kmesh-cni* +``` + +### Configuration Reset + +Reset to default settings: + +```shell +# Remove namespace labels +kubectl label namespace default istio.io/dataplane-mode- + +# Reset CNI +kubectl -n kmesh-system delete pod -l app=kmesh-cni +``` + +## Health Verification + +### System Health Check + +```shell +# Component status +kubectl get componentstatuses + +# Event monitoring +kubectl get events -n kmesh-system --sort-by='.lastTimestamp' + +# Resource usage +kubectl top pod -n kmesh-system +``` + +## Additional Resources + +- [Kmesh Architecture Guide](/docs/architecture/architecture.md) +- [Performance Tuning](/docs/performance/performance.md) +- [Community Support](/docs/community/contribute.md) + +For more complex issues, please refer to our [GitHub Issues](https://github.com/kmesh-net/kmesh/issues) or join our community channels. diff --git a/versioned_docs/version-1.2.0/setup/use-enhanced-kernel.md b/versioned_docs/version-1.2.0/setup/use-enhanced-kernel.md new file mode 100644 index 00000000..5dee962f --- /dev/null +++ b/versioned_docs/version-1.2.0/setup/use-enhanced-kernel.md @@ -0,0 +1,42 @@ +--- +title: Use Enhanced Kernel +sidebar_position: 3 +--- + +# Use Enhanced Kernel + +Some features of kmesh depend on enhanced kernel (e.g., L7 traffic control in `Kernel Native Mode`). To utilize it, you can use **openEuler 23.03**, which natively supports all features. + +You can follow the steps below to use enhanced kernel: + +## Download openEuler 23.03 image + +Download the image from: https://repo.openeuler.org/openEuler-23.03/ISO/ + +## Install the operation system + +Here, we take [VMware](https://www.vmware.com/products/workstation-pro/html.html) for example (you can also use other VM management tools). + +![image](images/install_openEuler.png) + +> **Notice:** **openEuler 23.03**'s kernel version is **6.1.19**. So you should select **其他 Linux 6.x 内核 64 位** (**Linux 6.x kernel 64bit**). + +Then, you can follow the [official blog](https://www.openeuler.org/zh/blog/20240306vmware/20240306vmware.html) to install it. + +## Install kernel headers + +Kmesh determines whether the enhanced kernel is utilized according to some kernel headers (e.g., `bpf.h`). So, you should install kernel headers by: + +```shell +yum install kernel-headers +``` + +Then, you should be able to find the kernel headers in the path `/usr/include/linux`. + +## Check whether you are ready to use enhanced kernel + +```shell +grep -q "FN(parse_header_msg)" /usr/include/linux/bpf.h && echo "enhanced" || echo "unenhanced" +``` + +Now you can follow the [deploy and develop guide](/docs/setup/develop-with-kind.md) to explore kmesh's full features. diff --git a/versioned_docs/version-1.2.0/transpot-layer/_category_.json b/versioned_docs/version-1.2.0/transpot-layer/_category_.json new file mode 100644 index 00000000..75db4c40 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Transport layer", + "position": 5, + "link": { + "type": "generated-index" + } +} \ No newline at end of file diff --git a/versioned_docs/version-1.2.0/transpot-layer/accesslog.md b/versioned_docs/version-1.2.0/transpot-layer/accesslog.md new file mode 100644 index 00000000..4f4e0258 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/accesslog.md @@ -0,0 +1,40 @@ +--- +sidebar_position: 6 +title: Access Logs +--- + +## Enable Kmesh access logging + +Kmesh accesslog can be enabled and disabled using kmeshctl. + +Please refer to the [Kmeshctl Monitoring Guide](../developer-guide/Kmeshctl-usage/kmeshctl-monitoring.md) + +## Detailed TCP Access Logs Generated by Kmesh + +Logs are generated by the Kmesh daemon during key stages of a TCP connection's lifecycle: + +- If the `connectionMetrics` is enabled, at regular 5-second intervals while the connection is active. + +- Upon connection closure + +Access Log Field Descriptions : + +| Name | Describe | +| -------------- | ------------------------------------------------------------------------------------------------------------------ | +| src.addr | Source address and port, source workload of the request | +| src.workload | Name of the Pod that initiated the request | +| src.namespace | Namespace of source worklaod | +| dst.addr | Destination address and port, destination workload of the request | +| dst.service | Hostname of deatination service | +| dst.workload | Name of the Pod receiving the request | +| dst.namespace | Namespace of destination workload | +| direction | The direction of the traffic. INBOUND means into the destination service, OUTBOUND means out of the source service | +| sent_bytes | Number of bytes sent for this connection | +| received_bytes | Number of bytes received for this connection | +| duration | Duration of this | + +An example log entry is shown below: + +```bash +accesslog: 2025-04-24 08:54:40.971980208 +0000 UTC src.addr=10.244.2.79:41978, src.workload=ws-client, src.namespace=default, dst.addr=10.244.2.78:8080, dst.service=ws-server-service.default.svc.cluster.local, dst.workload=ws-server, dst.namespace=default, start_time=2025-04-24 08:53:50.919245381 +0000 UTC, direction=OUTBOUND, state=BPF_TCP_ESTABLISHED, sent_bytes=3, received_bytes=227, packet_loss=0, retransmissions=0, srtt=40515us, min_rtt=34us, duration=50052.734827ms +``` diff --git a/versioned_docs/version-1.2.0/transpot-layer/images/grafana.png b/versioned_docs/version-1.2.0/transpot-layer/images/grafana.png new file mode 100644 index 00000000..7fdd698c Binary files /dev/null and b/versioned_docs/version-1.2.0/transpot-layer/images/grafana.png differ diff --git a/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg b/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg new file mode 100644 index 00000000..cb09218b Binary files /dev/null and b/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_deamon_monitoring.jpg differ diff --git a/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg b/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg new file mode 100644 index 00000000..189abc89 Binary files /dev/null and b/versioned_docs/version-1.2.0/transpot-layer/images/kmesh_map_and_operation_monitoring.jpg differ diff --git a/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-graph.png b/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-graph.png new file mode 100644 index 00000000..c64fb45c Binary files /dev/null and b/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-graph.png differ diff --git a/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-table.png b/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-table.png new file mode 100644 index 00000000..0e6e67b2 Binary files /dev/null and b/versioned_docs/version-1.2.0/transpot-layer/images/prometheus-table.png differ diff --git a/versioned_docs/version-1.2.0/transpot-layer/l4-metrics.md b/versioned_docs/version-1.2.0/transpot-layer/l4-metrics.md new file mode 100644 index 00000000..184c30d5 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/l4-metrics.md @@ -0,0 +1,191 @@ +--- +sidebar_position: 2 +title: Querying L4 Metrics from Prometheus +--- + +## Preparation + +### 1. Install Kmesh + +Please refer to the [quickstart guide](/docs/setup/quick-start.md) + +> **Note:** The following should be added to the Kmesh annotation: +> +> ```yaml +> annotations: +> prometheus.io/path: "status/metric" +> prometheus.io/port: "15020" +> prometheus.io/scrape: "true" +> ``` + +### 2. Configure Kmesh to manage the `default` namespace + +```bash +kubectl label namespace default istio.io/dataplane-mode=Kmesh +``` + +Expected output: + +```text +namespace/default labeled +``` + +### 3. Install the Prometheus Addon + +Istio provides a basic sample installation to quickly get Prometheus up and running: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +``` + +### 4. Deploy the tcp-echo and sleep applications + +```bash +# Deploy tcp-echo application +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/tcp-echo/tcp-echo.yaml + +# Deploy sleep application +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/sleep/sleep.yaml + +# Verify deployments +kubectl get po -A +``` + +Expected output: + +```bash +NAMESPACE NAME READY STATUS RESTARTS AGE +default sleep-bc9998558-pbfvk 1/1 Running 0 7m +default tcp-echo-7f676db574-mzmql 1/1 Running 0 7m +``` + +> **Important:** Confirm that sleep and tcp-echo are indeed [managed by kmesh](/docs/setup/quick-start.md#deploy-the-sample-applications). + +### 5. Enable required metrics + +Kmesh prometheus metrics can be enabled and disabled using kmeshctl. +Please refer to the [kmeshctl Guide](../developer-guide/Kmeshctl-usage/kmeshctl-monitoring.md) + +## Querying Metrics from Prometheus + +### Available Metrics + +Metrics monitored by Kmesh L4 at this stage: + +#### Workload Metrics + +Give information about traffic behavior and performance between workloads. + +| Name | Description | +| ---------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `kmesh_tcp_workload_connections_opened_total` | The total number of TCP connections opened to a workload | +| `kmesh_tcp_workload_connections_closed_total` | The total number of TCP connections closed to a workload | +| `kmesh_tcp_workload_received_bytes_total` | The size of the total number of bytes received in response to a workload over a TCP connection | +| `kmesh_tcp_workload_sent_bytes_total` | The size of the total number of bytes sent in response to a workload over a TCP connection | +| `kmesh_tcp_workload_conntections_failed_total` | The total number of TCP connections failed to a workload | +| `kmesh_tcp_retrans_total` | Total number of retransmissions of the workload over the TCP connection | +| `kmesh_tcp_packet_loss_total` | Total number of TCP packets lost between source and destination workload | + +#### Service Metrics + +Give information about traffic behavior and performance between services. + +| Name | Description | +| ------------------------------------- | --------------------------------------------------------------------------------------------- | +| `kmesh_tcp_connections_opened_total` | The total number of TCP connections opened to a service | +| `kmesh_tcp_connections_closed_total` | The total number of TCP connections closed to a service | +| `kmesh_tcp_received_bytes_total` | The size of the total number of bytes received in response to a service over a TCP connection | +| `kmesh_tcp_sent_bytes_total` | The size of the total number of bytes sent in response to a service over a TCP connection | +| `kmesh_tcp_conntections_failed_total` | The total number of TCP connections failed to a service | + +#### Connection Metrics + +Give information about traffic behavior and performance of a established tcp connection(duration > 5 seconds). These metrics are particularly valuable in clusters running workloads that establish long-lived TCP connections, such as databases, message brokers, audio/video streaming services, AI applications etc. +It is recommended to set the scrape interval to 5 seconds to ensure connection metrics are reliably captured. + +| Name | Description | +| ---------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `kmesh_tcp_connection_sent_bytes_total` | The total number of bytes sent over established TCP connection | +| `kmesh_tcp_connection_received_bytes_total` | The total number of bytes received over established TCP connection | +| `kmesh_tcp_connection_packet_lost_total` | Total number of packets lost during transmission in a TCP connection | +| `kmesh_tcp_connection_retrans_total` | The total number of retransmits over established TCP connection | + +### Querying Steps + +Here's how to view these metrics through Prometheus: + +#### 1. Verify that the Prometheus service is running in your cluster + +In Kubernetes environment, execute the following command: + +```bash +kubectl -n kmesh-system get svc prometheus +``` + +Expected output: + +```bash +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +prometheus ClusterIP 10.96.18.252 9090/TCP 24h +``` + +#### 2. Establish a TCP connection between applications in the mesh + +Create a TCP link between `sleep` and `tcp-echo` with the `nc` command: + +```bash +kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" \ + -c sleep -- sh -c 'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && \ + echo 'connection succeeded' || echo 'connection rejected' +``` + +Expected output: + +```text +hello port 9000 +connection succeeded +``` + +#### 3. Open the Prometheus UI + +Use the port-forward command to forward the traffic to Prometheus: + +```bash +kubectl port-forward --address 0.0.0.0 svc/prometheus 9090:9090 -n kmesh-system +``` + +Expected output: + +```text +Forwarding from 0.0.0.0:9090 -> 9090 +Handling connection for 9090 +Handling connection for 9090 +``` + +#### 4. Execute a Prometheus query + +In the "Expression" input box at the top of the web page, enter the text: + +```text +kmesh_tcp_connections_opened_total +``` + +The results will be similar to: + +![image](images/prometheus-table.png) + +You can also see the query results graphically by selecting the Graph tab underneath the Execute button. + +![image](images/prometheus-graph.png) + +## Cleanup + +1. Disable port-forward. + +2. Cleanup Prometheus: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +``` + +If you are not planning to explore any follow-on tasks, refer to the [quickstart cleanup](/docs/setup/quick-start.md#clean-up) instructions to shutdown the application. diff --git a/versioned_docs/version-1.2.0/transpot-layer/performace-monitoring.md b/versioned_docs/version-1.2.0/transpot-layer/performace-monitoring.md new file mode 100644 index 00000000..115d2177 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/performace-monitoring.md @@ -0,0 +1,63 @@ +--- +sidebar_position: 4 +title: Use Grafana to visualize kmesh performance monitoring +--- + +**NOTE:** This is an immature feature, so we turn it off by default, you can optionally turn it on. + +## Preparation + +1. Make default namespace managed by Kmesh +2. Set relevant args: + - Modify `bpf/kmesh/probes/performance_probe.h` by changing `#define PERF_MONITOR 0` to `#define PERF_MONITOR 1`. + - Change `--profiling=false` to `--profiling=true` in `deploy/yaml/kmesh.yaml`. (The default value of `--profiling` is false.) +3. Deploy bookinfo as sample application and sleep as curl client +4. Install namespace granularity waypoint for default namespace + + *The above steps could refer to [Install Waypoint | Kmesh](https://kmesh.net/docs/setup/quick-start) + +5. Refer to [quick start](https://kmesh.net/docs/setup/quick-start) to include test pods in kmesh management. Or include default namespace in kmesh management. + +6. Use `kmeshctl` to enable all of kmesh's monitoring functions: + +```sh +kmeshctl monitoring --all enable +``` + +1. Deploy prometheus and garafana: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +## Generate some continuous traffic between applications in the mesh + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +## Use grafana to visualize kmesh performance monitoring + +1. Use the port-forward command to forward traffic to grafana: + +```bash +kubectl port-forward --address 0.0.0.0 svc/grafana 3000:3000 -n kmesh-system +# Forwarding from 0.0.0.0:3000 -> 3000 +``` + +2. View the dashboard from browser + + Visit `Dashboards > Kmesh > Kmesh performance monitoring`: + + ![image](images/kmesh_deamon_monitoring.jpg) + ![image](images/kmesh_map_and_operation_monitoring.jpg) + +## Cleanup + +1. Remove prometheus and grafana: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` diff --git a/versioned_docs/version-1.2.0/transpot-layer/service-metrics.md b/versioned_docs/version-1.2.0/transpot-layer/service-metrics.md new file mode 100644 index 00000000..6483b862 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/service-metrics.md @@ -0,0 +1,51 @@ +--- +sidebar_position: 5 +title: Use Grafana to visualize service metrics +--- + +## Preparation + +1. Make default namespace managed by Kmesh +2. Deploy bookinfo as sample application and sleep as curl client +3. Install namespace granularity waypoint for default namespace + + _The above steps could refer to [Install Waypoint | Kmesh](/docs/application-layer/install_waypoint.md#preparation)_ + +4. Deploy prometheus and garafana: + +```bash +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl apply -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +## Generate some continuous traffic between applications in the mesh + +```bash +kubectl exec deploy/sleep -- sh -c "while true; do curl -s http://productpage:9080/productpage | grep reviews-v.-; sleep 1; done" +``` + +## Use grafana to visualize service metrics + +1. Use the port-forward command to forward traffic to grafana: + +```bash +kubectl port-forward --address 0.0.0.0 svc/grafana 3000:3000 -n kmesh-system +# Forwarding from 0.0.0.0:3000 -> 3000 +``` + +2. View the dashboard from browser + + Visit `Dashboards > Kmesh > Kmesh Service Dashboard`: + + ![image](images/grafana.png) + +## Cleanup + +1. Remove prometheus and grafana: + +```bash +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/prometheus.yaml +kubectl delete -f https://raw.githubusercontent.com/kmesh-net/kmesh/main/samples/addons/grafana.yaml +``` + +2. If you are not planning to explore any follow-on tasks, refer to the [Install Waypoint/Cleanup](/docs/application-layer/install_waypoint.md#cleanup) instructions to remove waypoint and shutdown the application. diff --git a/versioned_docs/version-1.2.0/transpot-layer/tcp-authorization.md b/versioned_docs/version-1.2.0/transpot-layer/tcp-authorization.md new file mode 100644 index 00000000..86d33070 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/tcp-authorization.md @@ -0,0 +1,265 @@ +--- +sidebar_position: 1 +title: TCP Authorization +--- + + +This guide shows you how to set up authorization policy for TCP traffic in Kmesh. + +## Before you begin + +- Understand the [AuthorizationPolicy](#authorizationpolicy) concept +- Install Kmesh + - Please refer to the [quickstart guide](/docs/setup/quick-start.md) +- Deploy the Sample Applications and configure them to be managed by Kmesh + - Please refer to [deploy applications](/docs/setup/quick-start.md#deploy-the-sample-applications) + - Modify the replicas to 2 in sleep deployment: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sleep +spec: + replicas: 2 + selector: + matchLabels: + app: sleep + template: + metadata: + labels: + app: sleep + spec: + terminationGracePeriodSeconds: 0 + serviceAccountName: sleep + containers: + - name: sleep + image: curlimages/curl + command: ["/bin/sleep", "infinity"] + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /etc/sleep/tls + name: secret-volume + volumes: + - name: secret-volume + secret: + secretName: sleep-secret + optional: true +``` + +- Verify application status to ensure the service application is managed by Kmesh: + +```bash +# Check pod status +kubectl get pod -o wide | grep sleep +``` + +Expected output: + +```bash +NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES +sleep-78ff5975c6-phhll 1/1 Running 0 30h 10.244.2.22 ambient-worker +sleep-78ff5975c6-plh7r 1/1 Running 0 30h 10.244.1.46 ambient-worker2 +``` + +```bash +# Verify Kmesh management +kubectl describe pod httpbin-65975d4c6f-96kgw | grep Annotations +``` + +Expected output: + +```text +Annotations: kmesh.net/redirection: enabled +``` + +## Configure ALLOW Authorization Policy + +1. Create an "allow-by-srcip" authorization policy for the httpbin workload: + +```bash +kubectl apply -f - < This policy allows requests only from the specified IP address `10.244.1.46/32`, which corresponds to the pod `sleep-78ff5975c6-plh7r`. + +2. Verify that requests from the allowed IP are successful: + +```bash +kubectl exec sleep-78ff5975c6-plh7r -- curl http://httpbin:8000/headers +``` + +Expected output: + +```json +{ + "headers": { + "Accept": "*/*", + "Host": "httpbin:8000", + "User-Agent": "curl/8.5.0" + } +} +``` + +3. Verify that requests from other IPs are denied: + +```bash +kubectl exec sleep-78ff5975c6-phhll -- curl http://httpbin:8000/headers +``` + +Expected output: + +```text +curl: (56) Recv failure: Connection reset by peer +``` + +4. Clean up the AuthorizationPolicy: + +```bash +kubectl delete AuthorizationPolicy allow-by-srcip -n default +``` + +## Configure DENY Authorization Policy + +1. Create a "deny-by-srcip" authorization policy for the httpbin workload: + +```bash +kubectl apply -f - < This policy denies requests from the specified IP address `10.244.1.46/32`, which corresponds to the pod `sleep-78ff5975c6-plh7r`. + +2. Verify that requests from the denied IP are blocked: + +```bash +kubectl exec sleep-78ff5975c6-plh7r -- curl "http://httpbin:8000/headers" +``` + +Expected output: + +```text +curl: (56) Recv failure: Connection reset by peer +``` + +3. Verify that requests from other IPs are allowed: + +```bash +kubectl exec sleep-78ff5975c6-phhll -- curl "http://httpbin:8000/headers" +``` + +Expected output: + +```json +{ + "headers": { + "Accept": "*/*", + "Host": "httpbin:8000", + "User-Agent": "curl/8.5.0" + } +} +``` + +4. Clean up the AuthorizationPolicy: + +```bash +kubectl delete AuthorizationPolicy deny-by-srcip -n default +``` + +## Clean up + +Please refer to the [cleanup guide](/docs/setup/quick-start.md#clean-up) + +## AuthorizationPolicy + +### AuthorizationPolicy Fields + +| Field | Type | Description | Required | +|---------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | +| `rules` | `Rule[]` | Optional. A list of rules to match the request. A match occurs when at least one rule matches the request. If not set, the match will never occur. This is equivalent to setting a default of deny for the target workloads if the action is ALLOW. | No | + +### Rule + +Rule matches requests from a list of sources that perform a list of operations subject to a list of conditions. A match occurs when at least one source, one operation and all conditions match the request. An empty rule is always matched. + +| Field | Type | Description | Required | +|--------|----------|---------------------------------------------------------------------------------------| -------- | +| `from` | `From[]` | Optional. `from` specifies the source of a request. If not set, any source is allowed.| No | +| `to` | `To[]` | Optional. `to` specifies the operation of a request. If not set, any operation is allowed. | No | + +#### Rule.From + +From includes a list of sources. + +| Field | Type | Description | Required | +|----------|----------|-------------------------------------------| -------- | +| `source` | `Source` | Source specifies the source of a request. | No | + +#### Rule.To + +To includes a list of operations. + +| Field | Type | Description | Required | +|-------------|-------------|-------------------------------------------------| -------- | +| `operation` | `Operation` | Operation specifies the operation of a request. | No | + +### Source + +Source specifies the source identities of a request. Fields in the source are ANDed together. + +For example, the following source matches if the principal is `admin` or `dev` AND the namespace is `prod` or `test` AND the ip is not `203.0.113.4`. + +```yaml +principals: ["admin", "dev"] +namespaces: ["prod", "test"] +notIpBlocks: ["203.0.113.4"] +``` + +| Field | Type | Description | Required | +|-----------------|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | +| `principals` | `string[]` | Optional. A list of peer identities derived from the peer certificate. The peer identity is in the format of `"/ns//sa/"`, for example, `"cluster.local/ns/default/sa/productpage"`. This field requires mTLS enabled and is the same as the `source.principal` attribute. If not set, any principal is allowed. | No | +| `notPrincipals` | `string[]` | Optional. A list of negative match of peer identities. | No | +| `namespaces` | `string[]` | Optional. A list of namespaces derived from the peer certificate. This field requires mTLS enabled and is the same as the `source.namespace` attribute. If not set, any namespace is allowed. | No | +| `notNamespaces` | `string[]` | Optional. A list of negative match of namespaces. | No | +| `ipBlocks` | `string[]` | Optional. A list of IP blocks, populated from the source address of the IP packet. Single IP (e.g. `203.0.113.4`) and CIDR (e.g. `203.0.113.0/24`) are supported. This is the same as the `source.ip` attribute. If not set, any IP is allowed. | No | +| `notIpBlocks` | `string[]` | Optional. A list of negative match of IP blocks. | No | + +### Operation + +Operation specifies the operations of a request. Fields in the operation are ANDed together. + +| Field | Type | Description | Required | +|------------|------------|-------------------------------------------------------------------------------------------| -------- | +| `ports` | `string[]` | Optional. A list of ports as specified in the connection. If not set, any port is allowed.| No | +| `notPorts` | `string[]` | Optional. A list of negative match of ports as specified in the connection. | No | diff --git a/versioned_docs/version-1.2.0/transpot-layer/xdp-auth.md b/versioned_docs/version-1.2.0/transpot-layer/xdp-auth.md new file mode 100644 index 00000000..cf07c791 --- /dev/null +++ b/versioned_docs/version-1.2.0/transpot-layer/xdp-auth.md @@ -0,0 +1,212 @@ +--- +sidebar_position: 3 +title: TCP Authorization in XDP +--- + +## Authorization in XDP + +Previously, we launched the [userspace authorization feature](/docs/transpot-layer/tcp-authorization.md), where authorization results were verified in userspace. This document explains how to enable authentication directly within the XDP program. Currently, XDP-based authentication supports verification based on port and IP addresses only. + +### How to enable XDP-based authentication + +We can use `kmeshctl` to enable XDP-based authentication: + +```bash +./kmeshctl authz enable +``` + +To modify BPF log level: + +```bash +./kmeshctl log <$kmeshnode1> --set bpf:debug +``` + +## Configure Deny Authorization Policies + +### Configure Destination Port Deny Authorization Policy + +Create a "deny-by-dstport" authorization policy for the Fortio workload that denies requests to the specified port address. In this example, traffic sent to port 8080 is denied: + +```yaml +# deny-by-dstport.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: deny-by-dstport +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - to: + - operation: + ports: + - "8080" +``` + +Apply the policy: + +```bash +kubectl apply -f deny-by-dstport.yaml +``` + +#### Testing the Policy + +The status code returned by the Fortio traffic confirms that traffic sent to port 8080 has been denied: + +```bash +kubectl exec -it fortio-client-deployment-6966bf9488-tpwpj -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.7:8080 +``` + +Expected output: + +```text +... +IP addresses distribution: +10.244.0.7:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3005.022 ms avg, 0.3 qps +``` + +Specific information will also be printed in the logs recorded by Kmesh: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +Expected output: + +```log +... +time="2024-12-25T15:23:12+08:00" level=info msg="[AUTH] DEBUG: port 8080 in destination_ports, matched" subsys=ebpf +time="2024-12-25T15:23:12+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +``` + +### Configure Source IP Deny Authorization Policy + +Create a policy to deny traffic from a specific source IP: + +```yaml +# deny-by-srcip.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: allow-by-srcip1 + namespace: default +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - from: + - source: + ipBlocks: + - 10.244.1.36 +``` + +Apply the policy: + +```bash +kubectl apply -f deny-by-srcip.yaml +``` + +#### Testing the Policy + +The status code returned by the Fortio traffic confirms that traffic sent from IP 10.244.1.36 has been denied: + +```bash +# The IP address of fortio-client-deployment-6966bf9488-m96qp is 10.244.1.36 +kubectl exec -it fortio-client-deployment-6966bf9488-m96qp -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.36:8080 +``` + +Expected output: + +```text +... +IP addresses distribution: +10.244.0.36:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3005.563 ms avg, 0.3 qps +``` + +Specific information will also be printed in the logs recorded by Kmesh: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +Expected output: + +```log +... +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +time="2024-12-26T15:06:14+08:00" level=info msg="[AUTH] DEBUG: no ports configured, matching by default" subsys=ebpf +time="2024-12-26T15:06:14+08:00" level=info msg="[AUTH] DEBUG: IPv4 match srcip: Rule IP: af40124, Prefix Length: 32, Target IP: af40124\n" subsys=ebpf +``` + +### Configure Destination IP Deny Authorization Policy + +Create a policy to deny traffic to a specific destination IP: + +```yaml +# deny-by-dstip.yaml +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: deny-dstip +spec: + selector: + matchLabels: + app: fortio-server + action: DENY + rules: + - when: + - key: destination.ip + values: ["10.244.0.36"] +``` + +Apply the policy: + +```bash +kubectl apply -f deny-by-dstip.yaml +``` + +#### Testing the Policy + +The status code returned by the Fortio traffic confirms that traffic sent to IP 10.244.0.36 has been denied: + +```bash +kubectl exec -it fortio-client-deployment-6966bf9488-m96qp -- fortio load -c 1 -n 1 -qps 0 -jitter=true 10.244.0.36:8080 +``` + +Expected output: + +```text +... +10.244.0.36:8080: 1 +Code -1 : 1 (100.0 %) +Response Header Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +Response Body/Total Sizes : count 1 avg 0 +/- 0 min 0 max 0 sum 0 +All done 1 calls (plus 0 warmup) 3004.974 ms avg, 0.3 qps +``` + +Specific information will also be printed in the logs recorded by Kmesh: + +```bash +kubectl logs -f kmesh-vlxhd -n kmesh-system +``` + +Expected output: + +```log +... +time="2024-12-26T15:05:22+08:00" level=info msg="[AUTH] DEBUG: rule matched, action: DENY" subsys=ebpf +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: no ports configured, matching by default" subsys=ebpf +time="2024-12-26T15:05:26+08:00" level=info msg="[AUTH] DEBUG: IPv4 match dstip: Rule IP: af40024, Prefix Length: 32, Target IP: af40024\n" subsys=ebpf +``` diff --git a/versioned_docs/version-1.2.0/welcome.md b/versioned_docs/version-1.2.0/welcome.md new file mode 100644 index 00000000..de875103 --- /dev/null +++ b/versioned_docs/version-1.2.0/welcome.md @@ -0,0 +1,32 @@ +--- +sidebar_position: 1 +title: Welcome +last_update: + date: "2025-02-22" +--- + +# Welcome to Kmesh: High-Performance and Low Overhead Service Mesh Data Plane + +Kmesh leverages eBPF and programmable kernels to offload traffic management to the OS, accelerating service mesh performance. Compared to traditional service meshes, it offers advantages such as low latency, being sidecarless, and low resource consumption. + +## Why Kmesh? + +- **Superior Performance**: Reduces service mesh latency through kernel-level optimizations +- **Resource Efficiency**: Minimizes overhead by implementing service governance at the OS layer +- **Simplified Operations**: Streamlines service mesh management with kernel-integrated traffic routing +- **Cloud Native Integration**: Seamlessly works with existing cloud-native infrastructure + +## Core Benefits + +| Benefit | Description | +| ----------------------- | ---------------------------------------------------------------------------- | +| Latency Reduction | Direct kernel path routing reduces service-to-service communication overhead | +| Resource Optimization | Lower CPU and memory usage through OS-layer implementation | +| Simplified Architecture | Fewer hops in service access paths improve overall performance | + +In the following docs, we will explain: + +- The [architecture](/docs/architecture/) and highlights advantages of Kmesh. +- The [quick start](/docs/setup/quick-start) of Kmesh. +- The [performance](/docs/performance/) of Kmesh. +- The [community](/docs/community/contribute.md) of Kmesh. diff --git a/versioned_sidebars/version-1.2.0-sidebars.json b/versioned_sidebars/version-1.2.0-sidebars.json new file mode 100644 index 00000000..caea0c03 --- /dev/null +++ b/versioned_sidebars/version-1.2.0-sidebars.json @@ -0,0 +1,8 @@ +{ + "tutorialSidebar": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} diff --git a/versions.json b/versions.json new file mode 100644 index 00000000..6a2a2a1e --- /dev/null +++ b/versions.json @@ -0,0 +1,3 @@ +[ + "1.2.0" +] diff --git a/yarn.lock b/yarn.lock index 71e8cc3c..3a6c6853 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2276,10 +2276,10 @@ dependencies: "@types/mdx" "^2.0.0" -"@node-rs/jieba-darwin-arm64@2.0.1": +"@node-rs/jieba-linux-x64-gnu@2.0.1": version "2.0.1" - resolved "https://registry.npmjs.org/@node-rs/jieba-darwin-arm64/-/jieba-darwin-arm64-2.0.1.tgz" - integrity sha512-10+nwGQ6KzXXJlIL/sELA6Fi6m7eJ7xJksBiKuw1kxKUgaJwtVfAG0iqRF+NRQv0Sdq7r3k5ew9K9y0+IYaEcA== + resolved "https://registry.npmjs.org/@node-rs/jieba-linux-x64-gnu/-/jieba-linux-x64-gnu-2.0.1.tgz" + integrity sha512-sq3J6L2ANTE25I9eVFq/nb57OtXcvUIeUD1CTKJxwgTKIVmcB2LyOZpWf20AjHRUfbMER9Klqg5dgyyO+Six+w== "@node-rs/jieba@^2.0.1": version "2.0.1" @@ -2322,10 +2322,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@parcel/watcher-darwin-arm64@2.5.1": +"@parcel/watcher-linux-x64-glibc@2.5.1": version "2.5.1" - resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz" - integrity sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw== + resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz" + integrity sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A== "@parcel/watcher@^2.4.1": version "2.5.1"