Currently, Dubbo only supports Mesh deployment in a Kubernetes environment, so you need to set up a Kubernetes environment before running this example. (It is recommended to use docker desktop for setup, which can directly run a Kubernetes environment.) https://docs.docker.com/desktop/install/mac-install/
Reference documentation for setting up Istio environment: Istio Installation Documentation(https://istio.io/latest/docs/setup/getting-started/) Note: When installing Istio, you need to enable first-party-jwt support (add –set values.global.jwtPolicy=first-party-jwt when using the istioctl tool), otherwise it will cause client authentication failure. Installation command reference:
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
Enter dubbo-dependencies-bom, change the grpc version to 1.41.0
<grpc.version>1.41.0</grpc.version>
Enter the dubbo-samples-xds directory and add the configuration:
dubbo.application.metadataServiceProtocol=dubbo
Package the dubbo code by switching to the dubbo root directory and executing the following command:
mvn clean package -DskipTests
Switch to the dubbo-samples code and import the just packaged dubbo code in the dubbo-samples-xds pom file. Next, modify the debug mode, taking dubbo-xds-consumer as an example: Change the docker file of dubbo-samples-consumer and set the debug mode to suspend=y, the modified docker file is as follows:
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:
cd dubbo-samples/dubbo-samples-xds
mvn clean package -DskipTests
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 ../
# Initialize namespace
kubectl apply -f https://raw.githubusercontent.com/apache/dubbo-samples/master/dubbo-samples-xds/deploy/Namespace.yml
# Switch namespace
kubens dubbo-demo
If kubens switch fails, just install kubectl.
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 commands, the docker desktop containers page looks like this, where dubbo-samples appear in several containers, including consumer and provider:

Check the k8s_server_dubbo-samples-xds-provider-XXX logs, and the following logs appear:
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

Check the k8s_server_dubbo-samples-xds-consumer-XXX logs, and it is waiting for the debug connection:
Open a terminal and enter the command to view available and Running status pods:
kubectl get pods

Enter the following command to map the pods’ ports to the local machine:
kubectl port-forward dubbo-samples-xds-consumer-64c6c6f444-kk2vr 31000:31000

Switch to idea, edit configuration, set the debugger mode to attach to remote JVM, choose the port exposed in the above docker file, select the module classpath as dubbo-samples-xds-consumer, and click debug to successfully connect.

You can see that the breakpoint has been successfully hit:
At this point, checking the logs of k8s_server_dubbo-samples-xds-consumer-XXX indicates it is successfully running:
