GithubHelp home page GithubHelp logo

Comments (8)

Isuama avatar Isuama commented on July 23, 2024

I found that application get registered in Eureka with the docker container IP rather than the IP I have used in the configuration.

from steeltoe.

dtillman avatar dtillman commented on July 23, 2024

@Isuama :
I pushed a Fortune Teller sample solution that has Docker enabled that should help you understand how to set this up. The sample was created using the built-in Visual Studio tooling for Docker and Docker compose. I added the Eureka service to the docker compose file so it starts up when you run the Fortune Teller sample using Docker compose.

https://github.com/SteeltoeOSS/Samples/tree/dev/Discovery/src/AspDotNetCoreDocker

Hope that helps.

Dave

from steeltoe.

Isuama avatar Isuama commented on July 23, 2024

Thank you @dtillman. I guess what you have done was, exposing the same port inside the docker container and consuming the same port from outside.
What I have found out, it was an issue from Steeltoe Discover Client as it always takes the host IP rather than the ipAddress mentioned in yml. It doesn't make any sense registering the IP, but in our case we needed it badly.
If we run docker command with the -h it solves the problem. But it is a workaround for us until Steeltoe fixes that. Appreciate your response.

from steeltoe.

dtillman avatar dtillman commented on July 23, 2024

@Isuama,

If you need to control what is registered in eureka, then you can set registrationMethod=hostName and then put a value in the hostName setting (DNS or IP address). That is what will end up getting registered in the eureka server and ultimately retrieved and used by the client.

As a FYI, in the sample I used docker-compose (DC) to run the FORTUNE-TELLER-UI, the FORTUNE-TELLER-SERVICE, and the Eureka server ( I just used a standard VS2017 project with Docker compose enabled).

DC creates a network with all those services running with-in it and makes networking very easy so you don't have to worry about the details. The DC network has a built-in hostname resolution service so all the registration/lookup happens on the DC network using names and addresses defined there. I also exposed each of the services(UI, eureka, etc) to the host using port mapping so you can access each container from a browser on the host. I probably could have not exposed the F-T-Service to the host since the communications from the UI to the F-T-Services is done on the DC network...but I elected to do so for testing.

Let me know if the above "hostName" doesn't work for you! Doc Link for registrationMethod
Dave

from steeltoe.

reeshuai avatar reeshuai commented on July 23, 2024

I also encountered the same problem.

from steeltoe.

Isuama avatar Isuama commented on July 23, 2024

@Isuama,

If you need to control what is registered in eureka, then you can set registrationMethod=hostName and then put a value in the hostName setting (DNS or IP address). That is what will end up getting registered in the eureka server and ultimately retrieved and used by the client.

As a FYI, in the sample I used docker-compose (DC) to run the FORTUNE-TELLER-UI, the FORTUNE-TELLER-SERVICE, and the Eureka server ( I just used a standard VS2017 project with Docker compose enabled).

DC creates a network with all those services running with-in it and makes networking very easy so you don't have to worry about the details. The DC network has a built-in hostname resolution service so all the registration/lookup happens on the DC network using names and addresses defined there. I also exposed each of the services(UI, eureka, etc) to the host using port mapping so you can access each container from a browser on the host. I probably could have not exposed the F-T-Service to the host since the communications from the UI to the F-T-Services is done on the DC network...but I elected to do so for testing.

Let me know if the above "hostName" doesn't work for you! Doc Link for registrationMethod
Dave

Dear Dave, Could you please explain then why they have a property like preferIpAddress and ipAddress. As per my understanding if we set preferIpAddress =true and set an IP it should work, isn't it. But trust me, It doesn't work.

from steeltoe.

jkonicki avatar jkonicki commented on July 23, 2024

This is worth investigating further and trying to address in a later release.

from steeltoe.

bart-vmware avatar bart-vmware commented on July 23, 2024

I'm pretty confident this works as expected, after #1280 has been merged. I've added a test to verify:

[Fact]
public async Task ExplicitlyConfiguredIPAddressIsPreserved()
{
    var appSettings = new Dictionary<string, string?>
    {
        ["Eureka:Instance:hostName"] = "ignored-host-name",
        ["Eureka:Instance:ipAddress"] = "192.168.10.20",
        ["Eureka:Instance:preferIpAddress"] = "true"
    };

    WebApplicationBuilder builder = WebApplication.CreateBuilder();
    builder.Configuration.AddInMemoryCollection(appSettings);
    builder.Services.AddEurekaDiscoveryClient();

    await using WebApplication webApplication = builder.Build();
    var appManager = webApplication.Services.GetRequiredService<EurekaApplicationInfoManager>();

    appManager.Instance.IPAddress.Should().Be("192.168.10.20");
    appManager.Instance.HostName.Should().Be("192.168.10.20");
}

Please let me know if this is still causing problems.

from steeltoe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.