Skip to content

Commit

Permalink
docs: nacos configstore component add config usage docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb0225 committed Jun 29, 2023
1 parent 313479d commit 75ddc23
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/en/component_specs/configuration/nacos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Nacos

## Configuration Items Description

Example: configs/config_nacos.json

| Field | Required | Description |
|-----------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------|
| address | Y | Nacos server address in <ip:port> format. By default, `/nacos` is used as the URL context, and `http` is used as the connection protocol. If the ACM connection field is not specified in the configuration file, this field is **required**. Multiple address addresses can be provided for connection. |
| timeout | N | Timeout for connecting to the Nacos server, in seconds. Default is 10s. |
| metadata.namespace_id | N | Nacos namespace for isolating configuration files at the namespace level. Default is empty, which represents using the "default" namespace in Nacos. |
| metadata.username | N | Username for Nacos service authentication verification. |
| metadata.password | N | Password for Nacos service authentication verification. |
| metadata.end_point | N | ACM mode field indicating the address of the connected Nacos service. [Reference](https://help.aliyun.com/document_detail/130146.html) |
| metadata.region_id | N | ACM mode field indicating the region where the Nacos service is located. |
| metadata.access_key | N | ACM mode field representing the access key in Alibaba Cloud Nacos service. |
| metadata.secret_key | N | ACM mode field representing the secret key in Alibaba Cloud Nacos service. |
| metadata.log_dir | N | Directory address for Nacos Go SDK output log files. Default directory name is `/tmp/layotto/nacos/logs`, and the default log name is `nacos-sdk.log`. |
| metadata.log_level | N | Log level for Nacos Go SDK output. Supported log levels are `debug`, `info`, `warn`, `error`. Default log level is `debug`. |
| metadata.cache_dir | N | File path for Nacos configuration local cache. Default cache path is `/tmp/layotto/nacos/cache`. |

> If any ACM field appears in the configuration file, Layotto connects to the Nacos service in ACM mode and ignores the `address`, `username`, `password`, and other fields.
## Other Configuration Items

The `app_id` field needs to be configured, and it is a required field. It represents the category of the app and supports configuring isolation for different app services at the configuration center level.

However, it is not added in the configuration of the Nacos ConfigStore component but in additional configuration items, making it convenient for other components that need to reuse `app_id`.

![img.png](../../../img/configuration/nacos/img.png)

## How to Start Nacos

You can refer to the [official Nacos documentation](https://nacos.io/en-us/docs/quick-start-docker.html) for instructions on how to start Nacos.

After deployment, you need to modify the Layotto [config file](https://github.com/mosn/layotto/blob/main/configs/config_nacos.json) and replace the Nacos server address and other information with your own.
Binary file added docs/img/configuration/nacos/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions docs/zh/component_specs/configuration/nacos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Nacos

## 配置项说明

示例:configs/config_nacos.json

| 字段 | 必填 | 说明 |
|-----------------------|-----|---------------------------------------------------------------------------------------------------------------------------------|
| address | Y | nacos 服务地址,填写 <ip:port> 模式即可。默认使用 `/nacos` 作为 url context,使用 http 作为连接协议。如果配置文件中没有填写 acm 连接字段,则这个字段是必填字段。可以填写多个 address 地址进行连接。 |
| timeout | N | 连接 nacos 服务的超时时间,单位秒。默认 10s. |
| metadata.namespace_id | N | nacos 命名空间,用于配置文件在命名空间级别的隔离。默认为空,代表使用 nacos 的 default 命名空间。 |
| metadata.username | N | nacos 服务 auth 校验所需的用户名。 |
| metadata.password | N | nacos 服务 auth 校验所需的密码。 |
| metadata.end_point | N | acm 模式字段,表示连接的nacos服务地址,[参考文档](https://help.aliyun.com/document_detail/130146.html) |
| metadata.region_id | N | acm 模式字段,表示 nacos 服务所在区域。 |
| metadata.access_key | N | acm 模式字段,表示阿里云 nacos 服务中的 access key。 |
| metadata.secret_key | N | acm 模式字段,表示阿里云 nacos 服务中的 secret key。 |
| metadata.log_dir | N | nacos go sdk 输出日志文件目录地址。默认目录名称为`/tmp/layotto/nacos/logs`,默认日志名称为`nacos-sdk.log`|
| metadata.log_level | N | nacos go sdk 输出日志等级。支持日志等级为 `debug`,`info`,`warn`,`error`。默认日志等级为`debug`|
| metadata.cache_dir | N | nacos 配置本地缓存文件路径。默认缓存路径为`/tmp/layotto/nacos/cache`|

> 当有任一 acm 字段出现在配置文件中,则 layotto 采用 acm 模式连接到 nacos 服务,忽略 address、username、password 等字段。
## 其他配置项

还需要配置 `app_id` 字段,是必填字段。表示该 app 的类别。支持在配置中心层面对不同的 app 服务进行配置隔离。

不过不是添加在 nacos configstore 组件的配置里,添加在而外的配置项中,方便其他需要使用 `app_id` 的组件复用。

![img.png](../../../img/configuration/nacos/img.png)

## 怎么启动 Nacos

nacos 的启动方式可以参考[nacos 官方文档](https://nacos.io/zh-cn/docs/quick-start-docker.html)

部署后需要修改Layotto的[config文件](https://github.com/mosn/layotto/blob/main/configs/config_nacos.json) ,将nacos服务器地址等信息改成您自己的。

0 comments on commit 75ddc23

Please sign in to comment.