このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。
Procedure
Authorizing a Source Code Repository
- Log in to CAE.
- Choose System Settings.
- Click Edit in the Source Code Repository Authorizations module. The Authorized Source Code Repository page is displayed.
- Click Create Authorization. The page for creating authorization is displayed.
- Click GitHub.
- Enter nacos-github in Authorization.
- Select OAuth for Method.
- Click Authenticate with OAuth.
- In the Service Statement dialog box, select I understand that the source code building function of the ServiceStage service collects the information above and agree to authorize the collection and use of the information. Click Confirm.
- After the authorization is complete, the GitHub login page is displayed.
- Enter the GitHub username or email address and password, and click Sign in. Wait until the OAuth authentication is complete and the CAE page is displayed.
- In the dialog box on the System Settings page, click OK to complete the authorization of the source code repository.
Creating and Deploying the nacos-provider Component
- Choose Components.
- Select the application and environment created in Prerequisites from the drop-down lists in the upper part of the page, and click Create Component.
- Configure the component by referring to Table 1.
Table 1 Basic information about the nacos-provider component Parameter
Description
Component
Enter a component name. In this practice, enter nacos-provider.
Version
Enter a component version.
In this practice, enter 1.0.0.
Specifications
Select instance specifications, for example, 0.5 Core and 1 GiB.
Instances
Set it to 1.
Code Source
Choose Source code repository > GitHub and configure authorization information.
- Authorization: nacos-github
- Username/Organization: username or email address authorized by the user
- Repository: nacos-example
- Branch: master
Language/Runtime System
Select Java17.
Custom Build
- Select Custom.
- Input the following information in the black box:
cd ./nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example && mvn clean package
Dockerfile Address
Enter ./.
- Click Configure Component.
- On the Component Configurations page, click Configure of the Cloud Service Engine (CSE) module. The Set CSE page is displayed.
- Click Registry/Configuration Center and select the Nacos engine created in Prerequisites.
- Click Save.
- On the Component Configurations page, click Edit in the Environment Variables module to configure the nacos-provider component.
- Click Add Environment Variable and enter the variable name and value.
- Name: JAVA_TOOL_OPTIONS
- Variable/Variable Reference: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
- Click OK.
- On the Component Configurations page, click Set and Deploy Component.
- Confirm the configuration information and click OK. Wait until the component deployment is complete.
Creating and Deploying the nacos-consumer Component
- In the navigation pane, choose Components to return to the components page.
- Select the application and environment created in Prerequisites from the drop-down lists in the upper part of the page, and click Create Component.
- Configure the component by referring to Table 2.
Table 2 Basic information about the nacos-consumer component Parameter
Description
Component
Enter a component name. In this practice, enter nacos-consumer.
Version
Enter a component version.
In this practice, enter 1.0.0.
Specifications
Select instance specifications, for example, 0.5 Core and 1 GiB.
Instances
Set it to 1.
Code Source
Choose Source code repository > GitHub and configure authorization information.
- Authorization: nacos-github
- Username/Organization: username or email address authorized by the user
- Repository: nacos-example
- Branch: master
Language/Runtime System
Select Java17.
Custom Build
- Select Custom.
- Input the following information in the black box:
cd ./nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-consumer-example && mvn clean package
Dockerfile Address
Enter ./.
- Click Configure Component.
- On the Component Configurations page, click Configure of the Cloud Service Engine (CSE) module. The Set CSE page is displayed.
- Click Registry/Configuration Center and select the Nacos engine created in Prerequisites.
NOTE:
The nacos-consumer and nacos-provider components must be bound to the same Nacos engine.
- Click Save.
- On the Component Configurations page, click Edit in the Environment Variables module to configure the nacos-consumer component.
- Click Add Environment Variable and enter the variable name and value.
- Name: JAVA_TOOL_OPTIONS
- Variable/Variable Reference: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
- Click OK.
- On the Component Configurations page, click Edit in the Access Mode module. The Set Access Mode page is displayed.
- On the Load Balancing tab, click Add Load Balancer and set parameters.
- Protocol: Select TCP.
- Listening Port: Enter 8080.
- Access Port: Enter an access port. In this practice, enter 14688.
- Click OK.
- On the Component Configurations page, click Set and Deploy Component and wait until the component deployment is complete.
- Confirm the configuration information and click OK. Wait until the component deployment is complete.
Calling a Microservice
- Choose Components.
- Select the nacos-consumer component and click
in the Access Address column to obtain the automatically generated external network access address.
Figure 1 Obtaining the external network access address - In the address box of the browser, enter http://External network access IP address:Access port/echo/{string}. The external network access IP address and access port are obtained in 2, and {string} is a custom string. Example: http://100.**.**.175:14688/echo/nacos-cae.
If the welcome page shown in the following figure is displayed, Nacos is successfully called.Figure 2 Calling a microservice engine
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot