From 624463a267937a2711a4708f1bcd8b92bd5f1dd8 Mon Sep 17 00:00:00 2001 From: chickenlj Date: Tue, 9 Jul 2024 14:31:41 +0800 Subject: [PATCH] update demo --- dubbo-demo/dubbo-demo-xds/README.md | 22 ++- .../dubbo-demo-xds/services_remote.yaml | 160 ++++++++++++++++++ 2 files changed, 176 insertions(+), 6 deletions(-) create mode 100644 dubbo-demo/dubbo-demo-xds/services_remote.yaml diff --git a/dubbo-demo/dubbo-demo-xds/README.md b/dubbo-demo/dubbo-demo-xds/README.md index c7d20f386dc..05aaba6ad47 100644 --- a/dubbo-demo/dubbo-demo-xds/README.md +++ b/dubbo-demo/dubbo-demo-xds/README.md @@ -1,6 +1,6 @@ # Dubbo-demo-xds -## Prepare Environment +### Prepare Environment (Optional) **To run this example, you need to have a kubernetes cluster with istio installed.** * If you don't have a k8s cluster, we recommend using docker desktop to get started. It has an embedded k8s cluster. * [install docker desktop](https://www.docker.com/products/docker-desktop/) @@ -11,15 +11,25 @@ * If you are not using docker desktop, you need to install docker to build and manage image. -* Use `docker run -d -p 5000:5000 --name local-registry registry:2` to enable local image repository. ---- -## Deploy Example +## Remote Deployment +Run the following command to deploy pre-prepared images: + +```shell +kubectl apply -f +``` + +## Local Development +If you have code changed locally and want to deploy it to remote cluster, follow the instructions below to learn how to build and deploy from source code. + +### Deploy Example +> Use `docker run -d -p 5000:5000 --name local-registry registry:2` to enable local image repository. + **When you have completed the above steps:** * Run `chmod 777 ./start.sh ./update.sh` * Then, use `./update.sh` to deploy example to Kubernetes. * Every time you change the code, you need to run `./update.sh` again to synchronize the changes to Kubernetes. ---- -## Start debugging + +### Start debugging * Every time you run ./update.sh, it will start port forward to demo containers. So you can use `Remote Debug` in your IDE to start debugging directly. * You can also simply use ./port_forward.sh to start port forward. diff --git a/dubbo-demo/dubbo-demo-xds/services_remote.yaml b/dubbo-demo/dubbo-demo-xds/services_remote.yaml new file mode 100644 index 00000000000..e45b95eeb73 --- /dev/null +++ b/dubbo-demo/dubbo-demo-xds/services_remote.yaml @@ -0,0 +1,160 @@ +apiVersion: v1 +kind: Service +metadata: + name: dubbo-demo-xds-consumer-service + labels: + app: dubbo-demo-xds-consumer + version: v1 + service: dubbo-demo-xds-consumer +spec: + ports: + - port: 50050 + targetPort: 50050 + name: tcp + - port: 31000 + targetPort: 31000 + name: debug + selector: + app: dubbo-demo-xds-consumer +--- +apiVersion: v1 +kind: Service +metadata: + name: dubbo-demo-xds-provider-service + labels: + app: dubbo-demo-xds-provider + version: v1 + service: dubbo-demo-xds-provider +spec: + ports: + - port: 50051 + targetPort: 50051 + name: tcp + - port: 31001 + targetPort: 31001 + name: debug + selector: + app: dubbo-demo-xds-provider + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dubbo-demo-xds-consumer + labels: + app: dubbo-demo-xds-consumer + version: v1 + service: dubbo-demo-xds-consumer +spec: + selector: + matchLabels: + app: dubbo-demo-xds-consumer + version: v1 + template: + metadata: + labels: + app: dubbo-demo-xds-consumer + version: v1 + spec: + serviceAccountName: dubbo-demo-xds-consumer + containers: + - name: dubbo-demo-xds-consumer + image: localhost:5000/dubbo-demo-xds-consumer:latest + imagePullPolicy: Always + ports: + - containerPort: 50050 + - containerPort: 31000 #for JVM remote debug + env: + - name: JAVA_TOOL_OPTIONS + value: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=31000" + replicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dubbo-demo-xds-provider + labels: + app: dubbo-demo-xds-provider + version: v1 + service: dubbo-demo-xds-provider +spec: + selector: + matchLabels: + app: dubbo-demo-xds-provider + version: v1 + template: + metadata: + labels: + app: dubbo-demo-xds-provider + version: v1 + spec: + serviceAccountName: dubbo-demo-xds-provider + containers: + - name: dubbo-demo-xds-provider + image: localhost:5000/dubbo-demo-xds-provider:latest + imagePullPolicy: Always + ports: + - containerPort: 50051 #for JVM remote debug + - containerPort: 31001 + env: + - name: JAVA_TOOL_OPTIONS + value: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=31001" + + replicas: 1 + +#Security configs +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: dubbo-demo-xds-consumer + labels: + app: dubbo-demo-xds-consumer + version: v1 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: dubbo-demo-xds-provider + labels: + app: dubbo-demo-xds-provider + version: v1 +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: dubbo-demo-xds-role-provider +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: dubbo-demo-xds-role-consumer +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: dubbo-demo-xds-consumer-role-binding + namespace: default +subjects: + - kind: ServiceAccount + name: dubbo-demo-xds-consumer +roleRef: + kind: Role + name: dubbo-demo-xds-role-consumer + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: dubbo-demo-xds-provider-role-binding + namespace: default +subjects: + - kind: ServiceAccount + name: dubbo-demo-xds-provider +roleRef: + kind: Role + name: dubbo-demo-xds-role-provider + apiGroup: rbac.authorization.k8s.io + +