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

Create services with a load balancer #21

Closed
geowa4 opened this issue Oct 13, 2015 · 56 comments
Closed

Create services with a load balancer #21

geowa4 opened this issue Oct 13, 2015 · 56 comments
Assignees

Comments

@geowa4
Copy link

geowa4 commented Oct 13, 2015

ecs-cli has been wonderful. For me, it's missing the ability to create services with load balancers. As a workaround, I define tasks with ecs-cli and use aws-cli (http://docs.aws.amazon.com/cli/latest/reference/ecs/create-service.html) to create the service with the load balancer.

@veered
Copy link

veered commented Oct 15, 2015

+1

2 similar comments
@MathieuLescure
Copy link

+1

@nacyot
Copy link

nacyot commented Oct 21, 2015

+1

@geowa4
Copy link
Author

geowa4 commented Oct 21, 2015

PSA: use the subscribe button on the right to indicate "+1".

@johndoran
Copy link

+1

@c05mic
Copy link

c05mic commented Jan 15, 2016

+1

@lox
Copy link

lox commented Jan 22, 2016

I wrote this in the meantime: https://github.com/lox/ecsy

@smiller171
Copy link

Has there been any traction on this?

@andymotta
Copy link

+1

5 similar comments
@MichaelNesterenko
Copy link

+1

@jedhassell
Copy link

+1

@khouse
Copy link

khouse commented Mar 12, 2016

+1

@AmielYanez
Copy link

+1

@sunghoaraipark
Copy link

+1

@smiller171
Copy link

@sunghoaraipark @vincetse There is a built in voting system now using reactions. it's better to add a thumbs up reaction to the first comment

@engineeringsnap
Copy link

Hi, do we have any idea of an ETA of when / if this might be available?

@mfonsen
Copy link

mfonsen commented May 23, 2016

As there has been no updates on this, I've been using Cloudformation for few months now for managing ECS. After recent updates, it supports all paramaters I need. Might work for some one else too.

@chrisheaththomas
Copy link

+1

1 similar comment
@ankitcha
Copy link

+1

@kaihendry
Copy link

@geowa4 @mfonsen Would be good if you iterate the steps you use on the cli to create a cluster with a load balancer.

My current work around is to create the service manually in the console but that can fraught with error and confusion. 😁

@ankitcha
Copy link

ankitcha commented Jul 27, 2016

@kaihendry I am using following script to do what @geowa4 mentioned in the description

ecs-cli configure --region us-east-1 --cluster $CLUSTER_NAME

# create ecs cluster of ec2 instances
ecs-cli up --keypair $KEY_PAIR --capability-iam --size $CLUSTER_SIZE --security-group $SSH_SECURITY_GROUP --vpc $VPC_ID --subnets $SUBNET_ID --image-id $AMI_ID --instance-type $INSTANCE_TYPE --verbose

# create task definition for a docker container
ecs-cli compose --file compose.yml --project-name $CLUSTER_NAME --verbose create

# create elb & add a dns CNAME for the elb dns
aws elb create-load-balancer --load-balancer-name "$CLUSTER_NAME" --listeners Protocol="TCP,LoadBalancerPort=8080,InstanceProtocol=TCP,InstancePort=8080" --subnets "$SUBNET_ID" --security-groups "$ECS_SECURITY_GROUP" --scheme internal

# create service with above created task definition & elb
aws ecs create-service --service-name "ecscompose-service-$CLUSTER_NAME" --cluster "$CLUSTER_NAME" --task-definition "ecscompose-$CLUSTER_NAME" --load-balancers "loadBalancerName=$CLUSTER_NAME,containerName=demo-service,containerPort=8080" --desired-count 1 --deployment-configuration "maximumPercent=200,minimumHealthyPercent=50" --role ecsServiceRole

and my compose.yml is as follows

demo-service:
    image: ubuntu
    ports:
        - "8080:8080"
    cpu_shares: 512
    mem_limit: 1024

@lrepolho
Copy link

+1

@smiller171
Copy link

@LeandroCR please use the built-in reaction system instead of a "+1" comment. GitHub finally implemented it (and you can sort issues by them) so let's use them! 😄

@TakaraShinya
Copy link

+1

@kaihendry
Copy link

kaihendry commented Sep 7, 2016

Thanks for the starting point @ankitcha

I maintain a set of scripts to setup the load balancer with ECS here: https://github.com/kaihendry/count

I really really hope ecs-cli gets some love and fixes this standard use case.

@dcworldwide
Copy link

dcworldwide commented Oct 17, 2016

New to ecs, dissapointed to see this use case isn't supported OOTB.

Thanks for sharing your workaround @ankitcha, I'm just wondering, if you subsequently scale out/in your containers, will ELB automatically update to reflect the changes?

@isaacd9
Copy link
Contributor

isaacd9 commented Jun 2, 2017

Excuse me, I just neglected to include the role flag, I did include it the the command. However, this does seem to be broken in that when the service has already been created, it doesn't fail without a role flag.

I'm not sure what you mean by "when the service is not created with the LB". I created the ELB and target groups from within the console and specified the ARN that I created in the command above. Do I need to do something other than just run the ecs-cli compose command?

@isaacd9
Copy link
Contributor

isaacd9 commented Jun 2, 2017

Oh, huh. I was wondering why it wasn't updating when I updated the service definition, but it seems like there's no way to update the load balancer a service uses?

It looks like it's missing from UpdateServiceInput which Up() uses under the hood. Not sure how I missed this. I see it's in the docs now. So sorry. :(

@yinshiua
Copy link
Contributor

yinshiua commented Jun 2, 2017

Ahh, I see. The behavior is expected, see documentation:

After you create a service, the target group ARN or load balancer name, container name, and container port specified in the service definition are immutable. You cannot add, remove, or change the load balancer configuration of an existing service. If you update the task definition for the service, the container name and container port that were specified when the service was created must remain in the task definition.

To avoid confusions here, we should add validations on cli when the service already exists.

@isaacd9
Copy link
Contributor

isaacd9 commented Jun 2, 2017

Yeah, this was really confusing and spent about an hour on it last night. An error message would be nice. :)

Cool if I submit a PR to this effect?

@yinshiua
Copy link
Contributor

yinshiua commented Jun 2, 2017

Sorry for the confusion, we definitely need better error handling here. I will create a new issue to follow up on this :) Thanks!

@shatil
Copy link

shatil commented Aug 3, 2017

@yinshiua, any idea whether this will be created using Cloudformation or via API?

@yinshiua
Copy link
Contributor

@shatil Currently, we only support using existing ELB in Create Service. We are planning on supporting the ELB creation possibly using the CloudFormation, but I do not have an ETA yet.

@kaihendry
Copy link

kaihendry commented Oct 18, 2017

Since I struggle with this every week, I thought I would share the script I use to deploy services with.
https://github.com/unee-t/bugzilla/blob/master/deploy.sh

Prerequisites:

  1. Create the ALB & targets manually in the console
  2. I assume you've setup ecsServiceRole with the AmazonEC2ContainerServiceRole policy

So I wish there was something to quickly create the ALBs, not easy thanks to a certificate dance.

And not sure what or where the role was supposed to be created. I do it manually on new accounts for want of a better way.

@mhaggerty042
Copy link

@kaihendry I get a 404 on your link

@kaihendry
Copy link

@jasonrhaas
Copy link

I see that the latest docs have already been updated with support for adding a load balancer to a service -- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-service.html

Any idea when this version will be released? Are there instructions with how to build from source?

@jordantomax
Copy link

@SoManyHs Is what @jasonrhaas says true? Or is the best way still to generate tasks using ecs-cli compose and use aws ecs create-service with the new task definition?

@PettitWesley
Copy link
Contributor

PettitWesley commented Jan 9, 2019

@jordantomax Yes, what @jasonrhaas mentions is correct. The docs link has changed: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-service-up.html

Here's an example of creating a service with an ALB (target group and ALB must already exist):

ecs-cli compose service up  \
--target-group-arn <your target group ARN> \
--container-name <your container name> \
--container-port <container port to route traffic too>

We're going to close this issue; for any new requests, please open a new issue and we'll respond accordingly. Thanks everyone for the feedback, we use this to help prioritize features for the ECS CLI!

@SoManyHs
Copy link
Contributor

SoManyHs commented Jan 9, 2019

@jordantomax If you wanted to create a load balancer in the same workflow as creating an ECS service (rather than specifying one that was created separately), you might be interested in checking out the CDK! https://awslabs.github.io/aws-cdk/refs/_aws-cdk_aws-ecs.html#include-a-load-balancer

@jordantomax
Copy link

jordantomax commented Jan 10, 2019

@PettitWesley I'm happy to create a new issue if you think that's the best thing to do. However, the command you listed still isn't working for me :(. The docs you sent are for create not for up. Was that your intention? Thanks in advance.

@PettitWesley
Copy link
Contributor

@jordantomax Yeah, please create a new issue if you want the ECS CLI to support creating a load balancer, as opposed to merely creating an ECS Service with an existing load balancer.

Sorry about the docs link- I've edited it to include the link for up. However, up works the same as create, it just additionally sets the desired count of the service to 1.

Also, for your problem with the command- can you create a new issue and show the exact command that you ran, etc? That would help us determine your problem. Right now, our best guess is that you might not be using the correct ARN with the target group flag- that's something we've seen before.

@jordantomax
Copy link

@PettitWesley Got it. Actually looks like my problem was that I was specifying the flag on the compose command instead of on the up command. All working now, thank you!

@pecigonzalo
Copy link

Will this parameter be added to the ecs-params.yml?

@PettitWesley
Copy link
Contributor

@pecigonzalo The parameter can definitely be added to the ECS Params yaml file! Can you create an issue so that we can track that request? Also, we always welcome pull requests, especially for small improvements like this :)

@pecigonzalo
Copy link

pecigonzalo commented Jan 17, 2019 via email

@PettitWesley
Copy link
Contributor

@pecigonzalo Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests