Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Application Layer",
"position": 7,
"link": {
"type": "generated-index"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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 "<title>.*</title>"
<title>Simple Bookstore App</title>
```

## 安装 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-
```

## 演示

<div className="video-responsive">
<iframe
src="https://www.youtube.com/embed/_mnPQU5SSFo"
frameborder="0"
allowfullscreen
></iframe>
</div>
Original file line number Diff line number Diff line change
@@ -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.
Loading