Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Amazon ECS clustering for Docker #361

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

grkvlt
Copy link
Member

@grkvlt grkvlt commented Oct 17, 2016

Creates a cluster of Docker Engines for use with Amazon ECS, running the ECS agent to register with the container service. Scaling and service replacement is managed by Brooklyn.

@grkvlt grkvlt changed the title Add ECS ECS clustering for Docker Add Amazon ECS clustering for Docker Oct 17, 2016
@grkvlt grkvlt force-pushed the aws-ec2-container-service branch 4 times, most recently from 38eb1b0 to ce8bef5 Compare October 17, 2016 14:24
@grkvlt
Copy link
Member Author

grkvlt commented Oct 17, 2016

The screenshot below shows what an ECS cluster managed by Brooklyn looks like in the AWS console, with one task running.

ecs-console

Copy link
Member

@aledsage aledsage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really must have tests for anything like this. We can't merge more and more functionality without being able to do automated regression testing.

Can you please add tests that use org.apache.brooklyn.test.framework (so that it can be run in a QA Framework). Without that, we should not consider merging this.

id: docker-cluster
name: "docker-cluster"

- id: docker-cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-cluster seems a strange name for this, to add to the catalog. We'll have lost the context that it is for EC2 container service. We should probably have "ecs" in the catalog item id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

services:
- type: ecs-cluster

- id: ecs-cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's scary that we're repeating all of these brooklyn.parameters in different entities in this same file.

What is the purpose of having ecs-cluster and docker-cluster as separate items?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the pattern used for all other Clocker templates. The way to avoid the duplication of parameters is to have some way of defining them as displayable, since this is just to have a subset that show up in the add application wizard...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grkvlt We can already define parameters as displayable by using the pinned flag. pinned: true which is the default means show the item in UI. Set it to false to hide.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neykov this is almost what we want; but was really looking for a way of indicating that a particular parameter defined in some child entity is to be displayed in the UI when a catalog entry that references that child is created? i.e. the Swarm TCP port is a property defined on the swarm-manager entity, but we want to propagate that up to the top level as an application configuration option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean now. Agree it would be nice to be able to express this case in a more concise way.

$brooklyn:config("docker.max.size")
autoscaler.resizeUpStabilizationDelay: 30s
autoscaler.resizeDownIterationMax: 0 # Disable scaling down
autoscaler.resizeDownStabilizationDelay: forever
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause us to track an infinite history of cluster load, so that we try to calculate what load has been happening "forever"? (I haven't dug into the Brooklyn AutoScalerPolicy to check; if you're going to rely on this, then perhaps we should have a test in Brooklyn? Or maybe we should just add an explicit autoscaler.resizeDownEnabled: false).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, not sure. We should definitely check, as this is part of the Swarm and Kubernetes autoscalers too.

Copy link
Member Author

@grkvlt grkvlt Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aledsage I had a closer look at this, and you're right. Since resizeDownIterationMax is zero, the delta for scale-down will always be zero, so the desired size is always equal to current size and scheduleResize(int) is never called to add a new smaller size. However this doesn't matter, as there is only one SizeHistory object, containing a TimeWindowedList sized to the Duration.of("forever") maximum.

long maxResizeStabilizationDelay = Math.max(getResizeUpStabilizationDelay().toMilliseconds(), getResizeDownStabilizationDelay().toMilliseconds());
recentDesiredResizes = new SizeHistory(maxResizeStabilizationDelay);

So, this should probably be changed to zero (i.e. removed, since that is the default value) as well, then the TimeWindowedList will be created using the desired resizeUpStabilizationDelay value. And, as noted above, this ought to be done for the Swam and Kubernetes auto-scalers as well.

sudo mkdir -p /var/log/ecs
sudo mkdir -p /var/lib/ecs/data
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A PREROUTING -p tcp -d 169.254.170.2 --dport 80 -j DNAT --to-destination 127.0.0.1:51679
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this assume CentOS 6? I'd have thought we'd want firewalld for CentOS 7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the ECS instructions for installing the agent

@grkvlt
Copy link
Member Author

grkvlt commented Oct 17, 2016

@aledsage what tests would you suggest? The ECS agent will fail on startup if an ECS cluster is not available with the provided name.

@grkvlt grkvlt force-pushed the aws-ec2-container-service branch 2 times, most recently from 041e2f8 to 53b8cf6 Compare October 18, 2016 13:35
@grkvlt grkvlt force-pushed the aws-ec2-container-service branch 2 times, most recently from 280813d to 8ddca62 Compare November 1, 2016 12:49
@grkvlt grkvlt added the feature label Nov 16, 2016
@grkvlt
Copy link
Member Author

grkvlt commented Dec 7, 2016

@aledsage I added tests that both check service up and also verify that custom sensors have correct values, this should be good to merge?

@grkvlt grkvlt force-pushed the aws-ec2-container-service branch from 3cb2a04 to 0a6dbd9 Compare May 16, 2017 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants