Nacos supports configuration context path (#12558)

This commit is contained in:
wetool19 2024-08-22 19:11:53 +08:00 committed by GitHub
parent 9e67130587
commit ba8c0035cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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 | - |

View File

@ -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;

View File

@ -76,6 +76,9 @@ public class ClusterModuleNacosProvider extends ModuleProvider {
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());

View File

@ -57,6 +57,9 @@ public class NacosConfigWatcherRegister extends FetchingConfigWatcherRegister {
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());

View File

@ -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;
}

View File

@ -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'

View File

@ -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:""}