Skip to content

Commit

Permalink
Nacos supports configuration context path (#12558)
Browse files Browse the repository at this point in the history
  • Loading branch information
wetool19 committed Aug 22, 2024
1 parent 9e67130 commit ba8c003
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* Get endpoint list order by timestamp desc.
* Support sort queries on metrics generated by eBPF receiver.
* Fix the compatibility with Grafana 11 when using label_values query variables.
* Nacos as config server and cluster coordinator supports configuration contextPath.

#### UI

Expand Down
1 change: 1 addition & 0 deletions docs/en/setup/backend/configuration-vocabulary.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The Configuration Vocabulary lists all available configurations provided by `app
| - | - | namespace | Namespace used by SkyWalking node coordination. | SW_CLUSTER_NACOS_NAMESPACE | public |
| - | - | internalComHost | The hostname registered in Nacos for internal communications of the OAP cluster. | SW_CLUSTER_INTERNAL_COM_HOST | - |
| - | - | internalComPort | The port registered in Nacos for internal communications of the OAP cluster. | SW_CLUSTER_INTERNAL_COM_PORT | -1 |
| - | - | contextPath | Nacos set contextPath. | SW_CLUSTER_NACOS_CONTEXT_PATH | - |
| - | - | username | Nacos Auth username. | SW_CLUSTER_NACOS_USERNAME | - |
| - | - | password | Nacos Auth password. | SW_CLUSTER_NACOS_PASSWORD | - |
| - | - | accessKey | Nacos Auth accessKey. | SW_CLUSTER_NACOS_ACCESSKEY | - |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ClusterModuleNacosConfig extends ModuleConfig {
private String namespace = "public";
private String internalComHost;
private int internalComPort = -1;
private String contextPath;
private String username;
private String password;
private String accessKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void prepare() throws ServiceNotProvidedException, ModuleStartException {
if (StringUtil.isNotEmpty(config.getUsername()) && StringUtil.isNotEmpty(config.getAccessKey())) {
throw new ModuleStartException("Nacos Auth method should choose either username or accessKey, not both");
}
if (StringUtil.isNotEmpty(config.getContextPath())) {
properties.put(PropertyKeyConst.CONTEXT_PATH, config.getContextPath());
}
if (StringUtil.isNotEmpty(config.getUsername())) {
properties.put(PropertyKeyConst.USERNAME, config.getUsername());
properties.put(PropertyKeyConst.PASSWORD, config.getPassword());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public NacosConfigWatcherRegister(NacosServerSettings settings) throws NacosExce
final Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr + ":" + port);
properties.put(PropertyKeyConst.NAMESPACE, settings.getNamespace());
if (StringUtil.isNotEmpty(settings.getContextPath())) {
properties.put(PropertyKeyConst.CONTEXT_PATH, settings.getContextPath());
}
if (StringUtil.isNotEmpty(settings.getUsername())) {
properties.put(PropertyKeyConst.USERNAME, settings.getUsername());
properties.put(PropertyKeyConst.PASSWORD, settings.getPassword());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class NacosServerSettings extends ModuleConfig {
private int period = 60;
private String username;
private String password;
private String contextPath;
private String accessKey;
private String secretKey;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ configuration:
period: 1
# the name of current cluster, set the name if you want to upstream system known.
clusterName: "default"
contextPath: '/nacos'
# Nacos auth username
username: 'nacos'
password: 'nacos'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cluster:
hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848}
# Nacos Naming namespace
namespace: ${SW_CLUSTER_NACOS_NAMESPACE:"public"}
contextPath: ${SW_CLUSTER_NACOS_CONTEXT_PATH:""}
# Nacos auth username
username: ${SW_CLUSTER_NACOS_USERNAME:""}
password: ${SW_CLUSTER_NACOS_PASSWORD:""}
Expand Down

0 comments on commit ba8c003

Please sign in to comment.