From f2894491ab3c51f0e2b0d9e14f0041c3fddbfa8d Mon Sep 17 00:00:00 2001 From: chickenlj Date: Sat, 7 Sep 2024 15:37:31 +0800 Subject: [PATCH] update demo --- 11-quickstart/Dockerfile | 1 + 11-quickstart/Kubernetes-manifests.yaml | 120 ++++++++++++++++++ 11-quickstart/README.md | 1 - .../src/main/resources/application.yml | 2 +- .../src/main/resources/templates/header.html | 2 +- .../src/main/resources/templates/home.html | 2 +- 6 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 11-quickstart/Kubernetes-manifests.yaml diff --git a/11-quickstart/Dockerfile b/11-quickstart/Dockerfile index 0bdf435008..8595ab0d6b 100644 --- a/11-quickstart/Dockerfile +++ b/11-quickstart/Dockerfile @@ -14,6 +14,7 @@ ARG APP_FILE # Remember to change the port according to the RPC protocol you select EXPOSE 50051 +EXPOSE 22222 # copy the JAR file into the root and rename RUN cp ./quickstart-service/target/${APP_FILE} app.jar diff --git a/11-quickstart/Kubernetes-manifests.yaml b/11-quickstart/Kubernetes-manifests.yaml new file mode 100644 index 0000000000..79307eda87 --- /dev/null +++ b/11-quickstart/Kubernetes-manifests.yaml @@ -0,0 +1,120 @@ +# Namespace +apiVersion: v1 +kind: Namespace +metadata: + name: dubbo-quickstart +--- +apiVersion: v1 +kind: Namespace +metadata: + name: dubbo-system +--- + +# Nacos +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nacos + namespace: dubbo-system +spec: + replicas: 1 + selector: + matchLabels: + app: nacos + template: + metadata: + labels: + app: nacos + spec: + containers: + - name: consumer + image: nacos-registry.cn-hangzhou.cr.aliyuncs.com/nacos/nacos-server:v2.1.2 + imagePullPolicy: Always + resources: + requests: + memory: "2Gi" + cpu: "500m" + ports: + - containerPort: 8848 + name: client + - containerPort: 9848 + name: client-rpc + env: + - name: NACOS_SERVER_PORT + value: "8848" + - name: NACOS_APPLICATION_PORT + value: "8848" + - name: PREFER_HOST_MODE + value: "hostname" + - name: MODE + value: "standalone" + - name: NACOS_AUTH_ENABLE + value: "true" +--- +apiVersion: v1 +kind: Service +metadata: + name: nacos + namespace: dubbo-system +spec: + type: ClusterIP + sessionAffinity: None + selector: + app: nacos + ports: + - port: 8848 + name: server + targetPort: 8848 + - port: 9848 + name: client-rpc + targetPort: 9848 +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: quickstart + namespace: dubbo-quickstart +spec: + replicas: 1 + selector: + matchLabels: + app: quickstart + template: + metadata: + labels: + app: quickstart + spec: + containers: + - name: quickstart + image: sca-registry.cn-hangzhou.cr.aliyuncs.com/dubbo/dubbo-quickstart:1.0 + imagePullPolicy: Always + ports: + - name: dubbo + containerPort: 50051 + protocol: TCP + - name: dubbo-qos + containerPort: 22222 + protocol: TCP + env: + - name: JAVA_TOOL_OPTIONS + value: "-Dnacos.address=nacos.dubbo-system.svc" +--- + +apiVersion: v1 +kind: Service +metadata: + name: quickstart + namespace: dubbo-quickstart +spec: + selector: + app: quickstart + ports: + - name: tcp + port: 50051 + targetPort: 50051 + - name: http + port: 22222 + targetPort: 22222 +--- + diff --git a/11-quickstart/README.md b/11-quickstart/README.md index d117e50d81..5cbbb8aa15 100644 --- a/11-quickstart/README.md +++ b/11-quickstart/README.md @@ -52,4 +52,3 @@ For further reference, please consider the following sections: * [Dubbo triple protocol reference](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/triple/) * [Dubbo Zookeeper registry configuration reference](https://docs.spring.io/spring-boot/docs/3.1.2/reference/htmlsingle/#web.servlet.spring-mvc.template-engines) - diff --git a/11-quickstart/quickstart-service/src/main/resources/application.yml b/11-quickstart/quickstart-service/src/main/resources/application.yml index edbf785f21..824e01bb00 100644 --- a/11-quickstart/quickstart-service/src/main/resources/application.yml +++ b/11-quickstart/quickstart-service/src/main/resources/application.yml @@ -14,7 +14,7 @@ dubbo: registry: - address: zookeeper://${zookeeper.address:127.0.0.1}:2181 + address: nacos://${nacos.address:127.0.0.1}:8848 protocol: name: tri port: 50051 diff --git a/online_bontique_demo/frontend/src/main/resources/templates/header.html b/online_bontique_demo/frontend/src/main/resources/templates/header.html index 3e8bff311d..857aa9b1c4 100644 --- a/online_bontique_demo/frontend/src/main/resources/templates/header.html +++ b/online_bontique_demo/frontend/src/main/resources/templates/header.html @@ -23,7 +23,7 @@ - + diff --git a/online_bontique_demo/frontend/src/main/resources/templates/home.html b/online_bontique_demo/frontend/src/main/resources/templates/home.html index d4e14616b4..876fa279b8 100644 --- a/online_bontique_demo/frontend/src/main/resources/templates/home.html +++ b/online_bontique_demo/frontend/src/main/resources/templates/home.html @@ -20,7 +20,7 @@ Home - +