Skip to content

Commit

Permalink
xds debug docs (#1860)
Browse files Browse the repository at this point in the history
* xds debug

* feat: improve appearence

* feat: adjust appearance

* feat: add engish version
  • Loading branch information
aamingaa committed Jan 17, 2023
1 parent 524ad29 commit 29da7cd
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 0 deletions.
9 changes: 9 additions & 0 deletions content/en/docs3-v2/java-sdk/reference-manual/mesh/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: docs
title: "Mesh Manual"
linkTitle: "Mesh Manual"
weight: 7
description: ""
---

An overview of Dubbo mesh usage and debugging methods.
157 changes: 157 additions & 0 deletions content/en/docs3-v2/java-sdk/reference-manual/mesh/mesh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
type: docs
title: "Debug Reference Documentation"
linkTitle: "Debug Reference Documentation"
weight: 2
description: "Describe how to debug Dubbo mesh proxyless mode."
---

## Pre-environment preparation

* docker environment
* kubernetes environment (docker desktop is recommended, with a graphical interface, and a small Kubernetes environment is embedded, and the following demonstration is also based on docker desktop)
* istio environment
* dubbo-samples code, the master branch is fine
* dubbo version >= 3.1.0
Build a Kubernetes environment
Currently Dubbo only supports Mesh deployment in the Kubernetes environment, so you need to set up the Kubernetes environment before running and starting this example. (It is recommended to use docker desktop to build, and you can run a kubernetes environment directly)
https://docs.docker.com/desktop/install/mac-install/

## Build Kubernetes environment

Currently Dubbo only supports Mesh deployment in the Kubernetes environment, so you need to set up the Kubernetes environment before running and starting this example. (It is recommended to use docker desktop to build, and you can run a kubernetes environment directly)
https://docs.docker.com/desktop/install/mac-install/

## Build Kubernetes environment

Build the Istio environment reference document:
Istio installation documentation (https://istio.io/latest/docs/setup/getting-started/)
Note: When installing Istio, you need to enable first-party-jwt support (add the --set values.global.jwtPolicy=first-party-jwt parameter when using the istioctl tool to install), otherwise it will cause client authentication to fail.
Attached installation command reference:

```java
curl -L https://istio.io/downloadIstio | sh -
cd istio-1.xx.x
export PATH=$PWD/bin:$PATH
istioctl install --set profile=demo --set values.global.jwtPolicy=first-party-jwt -y
```

## Start to build dubbo and dubbo-samples environment

Enter dubbo-dependencies-bom, change grpc version to 1.41.0

```java
<grpc.version>1.41.0</grpc.version>
```

Enter the dubbo-samples-xds directory and add configuration:

```java
dubbo.application.metadataServiceProtocol=dubbo
```

Package the dubbo code, switch to the dubbo root directory, and execute the following command to package:

```java
mvn clean package -DskipTests
```

Switch to the dubbo-samples code, and introduce the newly packaged dubbo code into the pom file of dubbo-samples-xds.
Next, modify the debug mode, taking dubbo-xds-consumer as an example:
Change the docker file of dubbo-samples-consumer and change the debug mode to suspend=y, the changed docker file is as follows:

```java
FROM openjdk:8-jdk
ADD ./target/dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar
EXPOSE 31000
CMD java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=31000 /dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar
```

Then execute the following command to package:

```java
cd dubbo-samples/dubbo-samples-xds
mvn clean package -DskipTests
```

## Build docker image

```java
cd ./dubbo-samples-xds-provider/
# dubbo-samples-xds/dubbo-samples-xds-provider/Dockerfile
docker build -t apache/dubbo-demo:dubbo-samples-xds-provider_0.0.1 .
cd ../dubbo-samples-xds-consumer/
# dubbo-samples-xds/dubbo-samples-xds-consumer/Dockerfile
docker build -t apache/dubbo-demo:dubbo-samples-xds-consumer_0.0.1 .
cd ../
```

## Create K8s namespace

```java
# Initialize the namespace
kubectl apply -f https://raw.githubusercontent.com/apache/dubbo-samples/master/dubbo-samples-xds/deploy/Namespace.yml

# switch namespace
kubens dubbo-demo
```

If the kubens switch is unsuccessful, just install kubectl
## deploy container

```java
cd ./dubbo-samples-xds-provider/src/main/resources/k8s
# dubbo-samples-xds/dubbo-samples-xds-provider/src/main/resources/k8s/Deployment.yml
# dubbo-samples-xds/dubbo-samples-xds-provider/src/main/resources/k8s/Service.yml
kubectl apply -f Deployment.yml
kubectl apply -f Service.yml
cd ../../../../../dubbo-samples-xds-consumer/src/main/resources/k8s
# dubbo-samples-xds/dubbo-samples-xds-consumer/src/main/resources/k8s/Deployment.yml
kubectl apply -f Deployment.yml
cd ../../../../../
```

After successfully executing the above command, the docker desktop containers page looks like this, in which there are several containers in dubbo-samples, including consumer and provider:

![docker-desktop.png](/imgs/user/docker-desktop.png)



View the k8s_server_dubbo-samples-xds-provider-XXX log, the following log appears:

```java
Dec 28, 2022 8:42:48 AM org.apache.dubbo.config.deploy.DefaultApplicationDeployer info
INFO: [DUBBO] Dubbo Application[1.1](dubbo-samples-xds-provider) is ready., dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
Dec 28, 2022 8:42:49 AM org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol info
INFO: [DUBBO] receive notification from xds server, type: type.googleapis.com/envoy.config.listener.v3.Listener, dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
Dec 28, 2022 8:42:53 AM org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol info
INFO: [DUBBO] receive notification from xds server, type: type.googleapis.com/envoy.config.listener.v3.Listener, dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
dubbo service started
```

![xds-provider-log.png](/imgs/user/xds-provider-log.png)

Check the k8s_server_dubbo-samples-xds-consumer-XXX log and find that it is waiting for a debug connection:
![xds-consumer-listener.png](/imgs/user/xds-consumer-listener.png)
Open the command terminal and enter the command to view the pods that are available and in the Running state:

```java
kubectl get pods
```
![k8s-pods.png](/imgs/user/k8s-pods.png)

Enter the following command to map the port of the pods to the local:

```java
kubectl port-forward dubbo-samples-xds-consumer-64c6c6f444-kk2vr 31000:31000
```

![port-forward.png](/imgs/user/port-forward.png)

Switch to idea, edit configuration, select attach to remote JVM for debugger mode, select the port of the above docker file expose for port, select dubbo-samples-xds-consumer for module classpath, and click debug to connect successfully
![remote-debug.png](/imgs/user/remote-debug.png)

You can see that the breakpoint has successfully entered:
![xds-debug-success.png](/imgs/user/xds-debug-success.png)
At this point, check the log of k8s_server_dubbo-samples-xds-consumer-XXX to see that it has been successfully running:
![xds-consumer-debug-success-log.png](/imgs/user/xds-consumer-debug-success-log.png)
10 changes: 10 additions & 0 deletions content/zh/docs3-v2/java-sdk/reference-manual/mesh/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
type: docs
title: "Mesh手册"
linkTitle: "Mesh手册"
weight: 7
description: ""
---

对 Dubbo mesh用法与debug方法进行了概述。

158 changes: 158 additions & 0 deletions content/zh/docs3-v2/java-sdk/reference-manual/mesh/mesh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
type: docs
title: "Debug参考文档"
linkTitle: "Debug参考文档"
weight: 2
description: "描述如何对Dubbo mesh proxyless模式进行debug。"
---

## 前置环境准备

* docker环境
* kubernetes环境(推荐docker desktop,图形化界面,还内嵌了一个小型的Kubernetes环境,后文演示也是基于docker desktop)
* istio环境
* dubbo-samples代码,master分支即可
* dubbo 版本 >= 3.1.0
搭建 Kubernetes 环境
目前 Dubbo 仅支持在 Kubernetes 环境下的 Mesh 部署,所以在运行启动本示例前需要先搭Kubernetes 环境。(建议采用docker desktop进行搭建,直接就可以运行一个kubernetes环境)
https://docs.docker.com/desktop/install/mac-install/

## 搭建 Kubernetes 环境

目前 Dubbo 仅支持在 Kubernetes 环境下的 Mesh 部署,所以在运行启动本示例前需要先搭Kubernetes 环境。(建议采用docker desktop进行搭建,直接就可以运行一个kubernetes环境)
https://docs.docker.com/desktop/install/mac-install/

## 搭建 Kubernetes 环境

搭建 Istio 环境参考文档:
Istio 安装文档(https://istio.io/latest/docs/setup/getting-started/)
注:安装 Istio 的时候需要开启 first-party-jwt 支持(使用 istioctl 工具安装的时候加上 --set values.global.jwtPolicy=first-party-jwt 参数),否则将导致客户端认证失败的问题。
附安装命令参考:

```java
curl -L https://istio.io/downloadIstio | sh -
cd istio-1.xx.x
export PATH=$PWD/bin:$PATH
istioctl install --set profile=demo --set values.global.jwtPolicy=first-party-jwt -y
```

## 开始构建dubbo和dubbo-samples环境

进入dubbo-dependencies-bom,更改grpc版本为1.41.0

```java
<grpc.version>1.41.0</grpc.version>
```

进入dubbo-samples-xds目录,新增配置:

```java
dubbo.application.metadataServiceProtocol=dubbo
```

打包dubbo代码,切换到dubbo根目录,执行以下命令进行打包:

```java
mvn clean package -DskipTests
```

切换到dubbo-samples代码,在dubbo-samples-xds的pom文件中引入刚打包好的dubbo代码。
接下来修改debug模式,以dubbo-xds-consumer为例:
更改dubbo-samples-consumer的docker file并更改调试模式为suspend=y, 更改后的docker file文件如下:

```java
FROM openjdk:8-jdk
ADD ./target/dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar
EXPOSE 31000
CMD java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=31000 /dubbo-samples-xds-consumer-1.0-SNAPSHOT.jar
```

随后执行以下命令进行打包:

```java
cd dubbo-samples/dubbo-samples-xds
mvn clean package -DskipTests
```

## 构建docker镜像

```java
cd ./dubbo-samples-xds-provider/
# dubbo-samples-xds/dubbo-samples-xds-provider/Dockerfile
docker build -t apache/dubbo-demo:dubbo-samples-xds-provider_0.0.1 .
cd ../dubbo-samples-xds-consumer/
# dubbo-samples-xds/dubbo-samples-xds-consumer/Dockerfile
docker build -t apache/dubbo-demo:dubbo-samples-xds-consumer_0.0.1 .
cd ../
```

## 创建K8s namespace

```java
# 初始化命名空间
kubectl apply -f https://raw.githubusercontent.com/apache/dubbo-samples/master/dubbo-samples-xds/deploy/Namespace.yml

# 切换命名空间
kubens dubbo-demo
```

如果kubens切换不成功,安装下kubectl即可
## 部署容器

```java
cd ./dubbo-samples-xds-provider/src/main/resources/k8s
# dubbo-samples-xds/dubbo-samples-xds-provider/src/main/resources/k8s/Deployment.yml
# dubbo-samples-xds/dubbo-samples-xds-provider/src/main/resources/k8s/Service.yml
kubectl apply -f Deployment.yml
kubectl apply -f Service.yml
cd ../../../../../dubbo-samples-xds-consumer/src/main/resources/k8s
# dubbo-samples-xds/dubbo-samples-xds-consumer/src/main/resources/k8s/Deployment.yml
kubectl apply -f Deployment.yml
cd ../../../../../
```

成功执行上述命令后的docker desktop containers页面长这样,其中dubbo-samples一共出现数个containers,包含consumer和provider:

![docker-desktop.png](/imgs/user/docker-desktop.png)



查看k8s_server_dubbo-samples-xds-provider-XXX日志,出现如下日志:

```java
Dec 28, 2022 8:42:48 AM org.apache.dubbo.config.deploy.DefaultApplicationDeployer info
INFO: [DUBBO] Dubbo Application[1.1](dubbo-samples-xds-provider) is ready., dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
Dec 28, 2022 8:42:49 AM org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol info
INFO: [DUBBO] receive notification from xds server, type: type.googleapis.com/envoy.config.listener.v3.Listener, dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
Dec 28, 2022 8:42:53 AM org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol info
INFO: [DUBBO] receive notification from xds server, type: type.googleapis.com/envoy.config.listener.v3.Listener, dubbo version: 1.0-SNAPSHOT, current host: 10.1.5.64
dubbo service started
```

![xds-provider-log.png](/imgs/user/xds-provider-log.png)

查看k8s_server_dubbo-samples-xds-consumer-XXX日志,发现其正等待debug连接:
![xds-consumer-listener.png](/imgs/user/xds-consumer-listener.png)
打开命令终端,输入命令查看可用并处于Running状态的pods:

```java
kubectl get pods
```
![k8s-pods.png](/imgs/user/k8s-pods.png)

输入以下命令将pods的端口映射到本地:

```java
kubectl port-forward dubbo-samples-xds-consumer-64c6c6f444-kk2vr 31000:31000
```

![port-forward.png](/imgs/user/port-forward.png)

切换到idea,edit configuration,debugger mode选择attach to remote JVM,port选择上面docker file expose的端口,module classpath选择dubbo-samples-xds-consumer,并点击debug,即可成功连接
![remote-debug.png](/imgs/user/remote-debug.png)

可以看到断点已经成功进来了:
![xds-debug-success.png](/imgs/user/xds-debug-success.png)
此时查看k8s_server_dubbo-samples-xds-consumer-XXX的日志可以看到已经成功在运行:
![xds-consumer-debug-success-log.png](/imgs/user/xds-consumer-debug-success-log.png)

Binary file added static/imgs/user/docker-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/user/k8s-pods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/user/port-forward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/user/remote-debug.png
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.
Binary file added static/imgs/user/xds-consumer-listener.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/user/xds-debug-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/imgs/user/xds-provider-log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 29da7cd

Please sign in to comment.