topcatv opened a new issue, #5601:
URL: https://github.com/apache/shenyu/issues/5601
### Question
When using shenyu-spring-boot-starter-client-springmvc, I want the host
registered with the gateway to be the hostname that I specify. How can I
achieve this?
Because I used the service in k8s to provide services, therefore I used the
following configuration in the configuration file.
```yaml
shenyu:
register:
registerType: http
serverLists: http://shenyu-admin-svc:9095
props:
username: admin
password: xxxxx
client:
http:
props:
host: biz-service
contextPath: /biz
appName: biz
```
However, after registering to the gateway, it was found that the upstream of
the divide was still the IP address of this service instead of the service
name. Through source code analysis, it was found in the
`org.apache.shenyu.client.springmvc.init.SpringMvcClientEventListener#buildURIRegisterDTO`
method
```java
try {
return URIRegisterDTO.builder()
.contextPath(getContextPath())
.appName(getAppName())
.protocol(protocol)
.host(super.getHost())
.port(Integer.valueOf(getPort()))
.rpcType(RpcTypeEnum.HTTP.getName())
.eventType(EventType.REGISTER)
.build();
} catch (ShenyuException e) {
throw new ShenyuException(e.getMessage() + "please config
${shenyu.client.http.props.port} in xml/yml !");
}
```
```java
public String getHost() {
return IpUtils.isCompleteHost(this.host) ? this.host
: IpUtils.getHost(this.host);
}
```
`IpUtils.isCompleteHost(this.host)` returns false, so the host IP will be
fetched. Can this be changed here to support configuring the host name or svc
in k8s?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]