Reputation: 3657
I've spent the last week trying to find a good example on how to properly achieve this but the internet doesn't seem to have anything out there...
I have what I'd say is a pretty basic Spring Cloud service. It includes Eureka, Zuul, Spring Config, and a handful of services.
I've worked out using the esc-cli
how I can easily create new tasks based on my docker-compose.yml
files. So I have two tasks
A management task which has basic things that at this stage don't need to scale, and having one instance of them is just fine for this project.
version: '2'
services:
mongo:
image: mongo
cpu_shares: 300
mem_limit: 268435456
ports:
- 27017:27017
config-service:
image: config-service
cpu_shares: 300
mem_limit: 268435456
ports:
- 8888:8888
environment:
- SPRING_PROFILES_ACTIVE=cloud
edge-service:
image: edge-service
cpu_shares: 300
mem_limit: 268435456
ports:
- 80:8080
environment:
- SPRING_PROFILES_ACTIVE=cloud
My second task has the clients of the above task.
version: '2'
services:
instance-service:
image: instance-service
cpu_shares: 300
mem_limit: 268435456
ports:
- 8081:8081
environment:
- SPRING_PROFILES_ACTIVE=cloud
restore-service:
image: restore-service:latest
cpu_shares: 300
mem_limit: 268435456
ports:
- 8082:8082
environment:
- SPRING_PROFILES_ACTIVE=cloud
I can easily create these tasks with a simple command such as ecs-cli compose --file management-task.yml --project-name management-task up
No problem there.
Where I hit an issue nothing can reach the Eureka
or the Config
services, so they all die. I've read all over the place that I can use an application load balance to allow the containers to talk to each other, however I can't actually find any information on how to do this.
The closest I've managed to find is a blog post here http://www.rahulkatte.com/index.html#!/microservice-part-V however they're not making use of Eureka being inside a task, nor a config server.
So, is there any comprehensive examples out there on how exactly you deploy a modern Spring Cloud app to AWS? Or does anyone have any pointers as to how to get my tasks/containers talking to each other, without just saying "Use a load balancers..."?
Thanks for your time.
Upvotes: 3
Views: 1715
Reputation: 3230
So I know this is sort of necro'ing a post, but there are no answers on here yet, so for posterity of anyone finding it in the future:
You're dealing with a "service discovery" problem here, and there are multiple ways to solve it:
You can use load balancers as you state. The way you do this is by creating an ALB, then creating a target group within that ALB. The target group's health check must the string literal "traffic port", because each ECS container will have a random port. Make sure that the security group for the EC2 instances attached to your ECS cluster allow incoming on all TCP ports. Note that if your ALB health check fails for whatever reason, the container will set to "draining" and be shut down.
ECS also recently (after your post, but is now GA) announced ECS service discovery. See this post.
You could use Kubernetes (EKS), which supports service discovery natively.
Upvotes: 3