ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.31k stars 1.63k forks source link

Load balancer sample using Consul and Least Connection [TCP] #1810

Closed ks1990cn closed 9 months ago

ks1990cn commented 9 months ago

Closes #1811

LoadBalancer Sample using Consul and Least Connection type.

I am creating this PR as a handy guide for local setup and running so any contributor can see loadbalancer in action with minimal repeated setup.

I think this can also help me / anyone as always present setup so just quickly go and make required changes to debug any requested changes / bug.

Proposed Changes

ks1990cn commented 9 months ago

@raman-m Here you go clean PR.

raman-m commented 9 months ago

@ggnaegi Welcome to code review! This PR will be a sample which goes to the samples folder. Currently we have no Load Balancer + Service Discovery coupling, I guess... Seems we have to compare this sample to the old OcelotServiceDiscovery sample too.

ks1990cn commented 9 months ago

@raman-m @ggnaegi are you reviewing it?

ks1990cn commented 9 months ago

When this gonna be merged @raman-m, just asking is there any dates when you do merges?

raman-m commented 9 months ago

@ggnaegi As a Consul service discovery expert, could you review this piece of coding art please? Let me know the results here and in Slack too plz!

raman-m commented 9 months ago

@ks1990cn commented on Dec 2 When this gonna be merged?

After all criteria of Dev Process are met!... See point 5

ks1990cn commented 9 months ago

@raman-m Is it fine now? image

I already had same structure just renamed my project files and folder.

Do you guys have any open slack channel or need to have any privilege to be part of it(just closed one)? @raman-m

ggnaegi commented 9 months ago

@raman-m Is it fine now? image

I already had same structure just renamed my project files and folder.

Do you guys have any open slack channel or need to have any privilege to be part of it(just closed one)? @raman-m

@ks1990cn Maybe you could provide a docker-compose project. I was away during week-end.

ks1990cn commented 9 months ago

@raman-m Is it fine now? image I already had same structure just renamed my project files and folder. Do you guys have any open slack channel or need to have any privilege to be part of it(just closed one)? @raman-m

@ks1990cn Maybe you could provide a docker-compose project. I was away during week-end.

@ggnaegi If I run on Docker-Compose, I need help for that, I am getting error 500 and my all services are working on docker. do you really need docker support for this sample or just running Consul on docker and rest locally will be okay to demo this?

ks1990cn commented 9 months ago

@ggnaegi @raman-m Here you can see I've created docker-compose and running in debugging mode.

I can hit my dowstream services and I am getting 500 error.

I need help here, what I am missing here?

LBQuery

ggnaegi commented 9 months ago

@ggnaegi @raman-m Here you can see I've created docker-compose and running in debugging mode.

I can hit my dowstream services and I am getting 500 error.

I need help here, what I am missing here?

LBQuery LBQuery

@ks1990cn it's normal, you are using localhost:8500 for your consul instance. You can't use that address for docker containers, it will never work. You should start your consul instance within the same network as the docker containers. So it's easier to start consul like this:

consul-service:
        image: "consul:latest"
        command: consul agent -dev -log-level=warn -ui -client=0.0.0.0
        hostname: consul
        ports:
            - "8500:8500"
            - "8600:8600"

and then call your docker instance with consul:8500

raman-m commented 9 months ago

Wow! So interesting battle I've missed... 😄

ks1990cn commented 9 months ago

Wow! So interesting battle I've missed... 😄

Haha! Need help here🤣 in #1811

raman-m commented 9 months ago

Haha... haha... But closing well reviewed PRs is not good...