Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Jul 9, 2024
1 parent dcdf235 commit 624463a
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 6 deletions.
22 changes: 16 additions & 6 deletions dubbo-demo/dubbo-demo-xds/README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand All @@ -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.
Expand Down
160 changes: 160 additions & 0 deletions dubbo-demo/dubbo-demo-xds/services_remote.yaml
Original file line number Diff line number Diff line change
@@ -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


0 comments on commit 624463a

Please sign in to comment.