Describe the bug
I need to set the hostname of the server that I want to register. The application is constantly getting the hostname of my computer even if I just type the following in the application.properties:
server.port=8887
spring.application.name=ConfigServer
spring.cloud.config.server.git.uri=https://github.com/mltech-dev/configs.git
spring.cloud.config.server.git.default.label=main
...
eureka.instance.prefer-ip-address=false
eureka.instance.hostname=config-server-dev.internal
eureka.client.registerWithEureka=true
eureka.client.service-url.defaultZone=${SERVICE_REGISTRY_URL:http://localhost:8761/eureka/}
I still get the following
DiscoveryClient_CONFIGSERVER/marcelos-mbp.lan:ConfigServer:8887: registering service..
where "marcelos-mbp.lan" is my hostname.
Originally, I wanted to put something like this:
eureka.instance.hostname=${CONFIG_SERVICE_DNS}
and inject the CONFIG_SERVICE_DNS with its proper DNS or ALB and right now I am constantly getting the IP.
This is happening in my local setup (Mac) and in ECS Fargate.
Sample The current version that I am running:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
....
Comment From: OlgaMaciaszek
Hello, @mfolivas please provide a minimal, complete, verifiable example that reproduces the issue.
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: kvmw
DiscoveryClient_CONFIGSERVER/marcelos-mbp.lan:ConfigServer:8887: registering service..
@mfolivas what you see in the above log is the default eureka.instance.instance-id and has nothing to do with the eureka.instance.hostname. the default instance-id is made of your machine hostname (or ip) and application name (host-name:app-name). You can set the instance-id in the application.properties, if you don't like the default one.