ufo 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e87e363feef7f56793f6fe3b7e09b4c702eeedbc82535eae4233e2c79b68950
4
- data.tar.gz: 8ff17b4dab22f9c92bec4de7248d75689f472813934ef9d51e16f13d7800d2bd
3
+ metadata.gz: 3e32cfe7ae9d1c54917cfca857b135fd1ad7dccc7f865ccc9f2b7187238c0b62
4
+ data.tar.gz: 39a546c17315befed8fcc630f382a613556b756e3ccd74e11fe20dc3a768d4c1
5
5
  SHA512:
6
- metadata.gz: 5506d4b6023131bacb147e7f297314fd82504721125dbd27b7f059f8461b9680a83576d835d71426dbeaa7823b049f742c51aa59df8567631b285d663773d86b
7
- data.tar.gz: aba58a3f64b8c17fec69eec866734941ddacbf8c5a72b8da576a8c5b4839bb36a7fcb4ecc1f9fa78d9c1328eef201cd358618571d13a9c105489470dbaf0f4e5
6
+ metadata.gz: ca820a40d91b2983413dfbf33d0a0ee31971f04e989711a827c413fa8708dc51c507e97bf5f889e094ab7b3d65a7dbc53001148fc59b716b6224e6a5ace17d73
7
+ data.tar.gz: 89856c014555a1685b101c62da4ee7b585197da7dcfe2ee113a79a857ef98ad6933eb66802a903b7f48ed0429ecaf9a3276afeeaf087dedcc001d7c3926e030c
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [4.1.0]
7
+ - Merge pull request #46 from tongueroo/ufo-status
8
+ - add ufo status command
9
+ - ufo ps --extra option
10
+ - update docs
11
+
6
12
  ## [4.0.3]
7
13
  - fix ufo ps for stopped task
8
14
  - improve docs
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: ECS Network Mode
3
+ ---
4
+
5
+ ## Pros and Cons: awsvpc vs bridge network mode
6
+
7
+ With network bridge mode, the Docker containers of multiple services share the EC2 container instance's security group. So you have less granular control over opening ports for specific services only. For example, let’s say service A and B both are configured use bridge network mode. If you open up port 3000 for service A, it will also open up port 3000 for service B because they use the same security group at the EC2 instance level.
8
+
9
+ One advantage of bridge mode is you can use dynamic port mapping and do not have to worry about network card limits.
10
+
11
+ With awsvpc network mode, you must consider the limit of ethernet cards for the instance type. The table that lists the limits are under section the aws EC2 docs under [IP Addresses Per Network Interface Per Instance Type](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html) For example, a t2.large instance has a limit of 3 ethernet cards. This means, at most, you can run 3 ECS tasks on that instance in awsvpc network mode. The network card limit ranges from 3 to 15 ethernet cards depending on the instance type.
12
+
13
+ The advantage of awsvpc mode is that since the ECS task has its own network card and security group, there’s more granular control of the permissions per ECS service. For example, when service A and B are using awsvpc mode, they can have different security groups associated with them. In this mode, ufo creates a security group and sets up the permissions so the load balancer can talk to the containers. You can also add additional security group to the `.ufo/settings/network/default.yml` config.
14
+
15
+ The following table summarizes the pros and cons:
16
+
17
+ Network mode | Pros | Cons
18
+ --- | ---
19
+ bridge | The numbers of containers you can run will not be limited due to EC2 instance network cards limits. | Less fine grain security control over security group permissions with multiple ECS services.
20
+ awsvpc | Fine grain security group permissions for each ECS service. | The number of containers can be limited by the number of network cards the EC2 instance type supports.
21
+
22
+ <a id="prev" class="btn btn-basic" href="{% link _docs/security-groups.md %}">Back</a>
23
+ <a id="next" class="btn btn-primary" href="{% link _docs/ssl-support.md %}">Next Step</a>
24
+ <p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -21,20 +21,30 @@ Here are examples of each of them:
21
21
  # Disable creating ELB
22
22
  ufo ship demo-web --elb=false
23
23
 
24
- ## ELB Retained
24
+ ## Web Service Convention
25
25
 
26
- Ufo retains the ELB setting. So future `ufo ship` commands will not suddenly remove the load balancer. If you need to change the elb setting, then you need to explicitly set a new `--elb` value.
26
+ By convention, if the container name is 'web' in the task definition. Deployments of new services will automatically create a load balancer. So if the task definition looks something like the following then a load balancer will automatically be created:
27
27
 
28
- Important: Adding and removing load balancers will change the ELB DNS. Please take pre-caution using the elb options. This risk is mitigated if you have configured [Route53 support]({% link _docs/route53-support.md %}).
28
+ ```json
29
+ {
30
+ "containerDefinitions": [
31
+ {
32
+ "name": "web",
33
+ ...
34
+ ```
29
35
 
30
- ## Web Service Convention
31
-
32
- By convention, if the container name is 'web' in the task definition. Deployments of new services will automatically create a load balancer. The behavior can be disabled with `--elb=false` for web containers.
36
+ The behavior can be disabled with `--elb=false` for web containers.
33
37
 
34
38
  ufo ship demo-web --elb=false
35
39
 
36
40
  For non-web container the `--elb` option must be explicitly set to `--elb=true` if you want a load balancer to be created.
37
41
 
42
+ ## ELB Retained
43
+
44
+ Ufo retains the ELB setting. So future `ufo ship` commands will not suddenly remove the load balancer. If you need to change the elb setting, then you need to explicitly set a new `--elb` value.
45
+
46
+ Important: Adding and removing load balancers will change the ELB DNS. Please take pre-caution using the elb options. This risk is mitigated if you have configured [Route53 support]({% link _docs/route53-support.md %}).
47
+
38
48
  ## ELB Types: Application and Network
39
49
 
40
50
  Ufo supports application and network load balancer types. To specify the type use `--elb-type`. Examples:
@@ -61,6 +71,8 @@ To remove the EIPs but still keep the network load balancer, you can specify eit
61
71
  UFO_FORCE_TARGET_GROUP=1 ufo deploy demo-web --elb-eip-ids ' ' --elb-type network
62
72
  UFO_FORCE_TARGET_GROUP=1 ufo deploy demo-web --elb-eip-ids 'empty' --elb-type network
63
73
 
74
+ Note be careful using the UFO_FORCE_TARGET_GROUP option. If the deploy fails, then the CloudFormation stack rolls back and can leave the target group with healthy targets resulting in downtime. If it's an production service and you are changing the load balancer type or eip IPs, it is recommended to instead create a temporary additional ECS service, do a DNS switch, and then remove the old ECS.
75
+
64
76
  ## Load Balancer Implementation
65
77
 
66
78
  Under the hood, ufo implements load balancer support with CloudFormation. You can see these resources by visiting the CloudFormation console and clicking on the corresponding stack. Here's an example:
@@ -32,23 +32,6 @@ In general, ports below 32768 are outside of the ephemeral port range. So an eas
32
32
 
33
33
  If you are using a network load balancer and are running bridge network mode, then you need to whitelist ports 32768 to 65535 to `0.0.0.0/0`. This is because network load balancers operate at layer 4 of the OSI model and cannot be assigned security groups, so they use the security group of the instance. If you feel this is too loose of permissions, you can use awsvpc mode. There are some considerations for awsvpc mode though which is discussed next.
34
34
 
35
- ## Pros and Cons: awsvpc vs bridge network mode
36
-
37
- With network bridge mode, the Docker containers of multiple services share the EC2 container instance's security group. So you have less granular control over opening ports for specific services only. For example, let’s say service A and B both are configured use bridge network mode. If you open up port 3000 for service A, it will also open up port 3000 for service B because they use the same security group at the EC2 instance level.
38
-
39
- One advantage of bridge mode is you can use dynamic port mapping and do not have to worry about network card limits.
40
-
41
- With awsvpc network mode, you must consider the limit of ethernet cards for the instance type. The table that lists the limits are under section the aws EC2 docs under [IP Addresses Per Network Interface Per Instance Type](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html) For example, a t2 large instance has a limit of 3 Ethernet cards. This means, at most, you can run 3 ECS tasks on that instance in awsvpc network mode.
42
-
43
- The advantage of awsvpc mode is that since the ECS task has its own network card and security group, there’s more granular control of the permissions per ECS service. For example, when service A and B are using awsvpc mode, they can have different security groups associated with them. In this mode, ufo creates a security group and sets up the permissions so the load balancer can talk to the containers. You can also add additional security group to the `.ufo/settings/network/default.yml` config.
44
-
45
- The following table summarizes the pros and cons:
46
-
47
- Network mode | Pros | Cons
48
- --- | ---
49
- bridge | The numbers of containers you can run will not be limited due to EC2 instance network cards limits. | Less fine grain security control over security group permissions with multiple ECS services.
50
- awsvpc | Fine grain security group permissions for each ECS service. | The number of containers can be limited by the number of network cards the EC2 instance type supports.
51
-
52
35
  <a id="prev" class="btn btn-basic" href="{% link _docs/load-balancer.md %}">Back</a>
53
- <a id="next" class="btn btn-primary" href="{% link _docs/ssl-support.md %}">Next Step</a>
36
+ <a id="next" class="btn btn-primary" href="{% link _docs/ecs-network-mode.md %}">Next Step</a>
54
37
  <p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -36,6 +36,6 @@ target_group:
36
36
 
37
37
  The protocol in the case of the network load balancer is TCP and is configured to TCP by default by ufo for Network Load Balancers, so you don't have to configure the protocol.
38
38
 
39
- <a id="prev" class="btn btn-basic" href="{% link _docs/security-groups.md %}">Back</a>
39
+ <a id="prev" class="btn btn-basic" href="{% link _docs/ecs-network-mode.md %}">Back</a>
40
40
  <a id="next" class="btn btn-primary" href="{% link _docs/route53-support.md %}">Next Step</a>
41
41
  <p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -8,7 +8,7 @@ A major change in ufo from version 3 to 4 is that the ECS service is now created
8
8
 
9
9
  The upgrade path recommended here should result in zero downtime. It is effectively a blue/green deployment with a DNS switchover.
10
10
 
11
- 1. Run `ufo upgrade v3to4`
11
+ 1. Run `ufo upgrade v3to4` in your project folder.
12
12
  2. Check the changed files.
13
13
  3. Run `ufo ship SERVICE`.
14
14
  4. Confirm your new service is working. `ufo ps` and `ufo apps` is useful.
@@ -27,6 +27,7 @@
27
27
  <li><a href="{% link _docs/ufo-current.md %}">Ufo Current</a></li>
28
28
  <li><a href="{% link _docs/load-balancer.md %}">Load Balancer</a></li>
29
29
  <li><a href="{% link _docs/security-groups.md %}">Security Groups</a></li>
30
+ <li><a href="{% link _docs/ecs-network-mode.md %}">ECS Network Mode</a></li>
30
31
  <li><a href="{% link _docs/ssl-support.md %}">SSL Support</a></li>
31
32
  <li><a href="{% link _docs/route53-support.md %}">Route53 Support</a></li>
32
33
  <li><a href="{% link _docs/faq.md %}">FAQ</a></li>
@@ -2,7 +2,7 @@
2
2
  Option | Description
3
3
  ------------- | -------------
4
4
  `--cluster` | This decides what cluster to use. This can also be set in ufo/settings.yml covered in [Settings]({% link _docs/settings.md %}). The cli option takes highest precedence.
5
- `--ecr-keep` | This integer option determines how many old docker images to keep around. Ufo will automatically delete and clean up docker images at the end of this process. The default is reasonable large at 30.
5
+ `--ecr-keep` | This integer option determines how many old docker images to keep around. Ufo will automatically delete and clean up docker images at the end of this process. The default is to keep all. If you set this, set it at a reasonable high number like 30.
6
6
  `--elb-eip-ids` | EIP Allocation ids to use for network load balancer. If specified then `--elb-type` is automatically assumed to be `network`.
7
7
  `--elb-type` | ELB type: application or network. Keep current deployed elb type when not specified.
8
8
  `--elb` | Decides to create elb, not create elb or use existing target group.
data/lib/ufo.rb CHANGED
@@ -36,6 +36,7 @@ module Ufo
36
36
  autoload :Setting, 'ufo/setting'
37
37
  autoload :Ship, 'ufo/ship'
38
38
  autoload :Stack, 'ufo/stack'
39
+ autoload :Status, 'ufo/status'
39
40
  autoload :Stop, 'ufo/stop'
40
41
  autoload :Task, 'ufo/task'
41
42
  autoload :Tasks, 'ufo/tasks'
@@ -156,6 +156,7 @@ module Ufo
156
156
  desc "ps SERVICE", "Show process info on ECS service."
157
157
  long_desc Help.text(:ps)
158
158
  option :summary, type: :boolean, default: true, desc: "Display summary header info."
159
+ option :extra, type: :boolean, default: false, desc: "Display extra debugging columns."
159
160
  def ps(service=:current)
160
161
  Ps.new(service, options).run
161
162
  end
@@ -172,6 +173,12 @@ module Ufo
172
173
  Stop.new(service, options).run
173
174
  end
174
175
 
176
+ desc "status SERVICE", "Status of ECS service. Essentially, status of CloudFormation stack"
177
+ long_desc Help.text(:status)
178
+ def status(service=:current)
179
+ Status.new(service, options).run
180
+ end
181
+
175
182
  desc "completion *PARAMS", "Prints words for auto-completion."
176
183
  long_desc Help.text("completion")
177
184
  def completion(*params)
@@ -94,7 +94,7 @@ EOL
94
94
  Example:
95
95
  ufo #{ARGV.first} SERVICE
96
96
  You can also set a current service to be remembered with:
97
- ufo current SERVICE
97
+ ufo current --service SERVICE
98
98
  EOL
99
99
  exit 1
100
100
  # if want to display full help menu:
@@ -14,8 +14,12 @@ module Ufo
14
14
 
15
15
  cloudformation.delete_stack(stack_name: @stack_name)
16
16
  puts "Deleting CloudFormation stack with ECS resources: #{@stack_name}."
17
+
17
18
  return unless @options[:wait]
19
+ start_time = Time.now
18
20
  status.wait
21
+ took = Time.now - start_time
22
+ puts "Time took for deletion: #{status.pretty_time(took).green}."
19
23
  end
20
24
 
21
25
  def are_you_sure?
@@ -19,7 +19,7 @@ module Ufo
19
19
  end
20
20
 
21
21
  resp = ecs.describe_tasks(tasks: task_arns, cluster: @cluster)
22
- display_info(resp)
22
+ display_tasks(resp)
23
23
 
24
24
  display_scale_help
25
25
  display_target_group_help
@@ -74,12 +74,17 @@ module Ufo
74
74
 
75
75
  puts "There is an issue scaling the #{@service.colorize(:green)} service to #{service.desired_count}. Here's the error:"
76
76
  puts error_event.message.colorize(:red)
77
+ if service.launch_type == "EC2"
78
+ puts "If AutoScaling is set up for the container instances, it can take a little time to add additional instances. You'll see this message until the capacity is added."
79
+ end
77
80
  end
78
81
 
79
- def display_info(resp)
82
+ def display_tasks(resp)
80
83
  table = Text::Table.new
84
+ Task.extra_columns = @options[:extra]
81
85
  table.head = Task.header
82
- resp["tasks"].each do |t|
86
+ tasks = resp["tasks"].sort_by { |t| t["task_arn"] }
87
+ tasks.each do |t|
83
88
  task = Task.new(t)
84
89
  table.rows << task.to_a unless task.hide?
85
90
  end
@@ -1,7 +1,9 @@
1
1
  class Ufo::Ps
2
2
  class Task
3
3
  def self.header
4
- %w[Id Name Release Started Status Notes]
4
+ header = %w[Id Name Release Started Status Notes]
5
+ header << "Container Instance" if extra_columns
6
+ header
5
7
  end
6
8
 
7
9
  def initialize(task)
@@ -9,7 +11,9 @@ class Ufo::Ps
9
11
  end
10
12
 
11
13
  def to_a
12
- [id, name, release, started, status, notes]
14
+ row = [id, name, release, started, status, notes]
15
+ row << container_instance_arn if extra_columns
16
+ row
13
17
  end
14
18
 
15
19
  def id
@@ -22,6 +26,10 @@ class Ufo::Ps
22
26
  @task["containers"].first["name"]
23
27
  end
24
28
 
29
+ def container_instance_arn
30
+ @task['container_instance_arn']
31
+ end
32
+
25
33
  def release
26
34
  @task["task_definition_arn"].split('/').last
27
35
  end
@@ -78,5 +86,18 @@ class Ufo::Ps
78
86
  start_time.strftime("%m/%d/%Y")
79
87
  end
80
88
  end
89
+
90
+ @@extra_columns = false
91
+ def self.extra_columns=(val)
92
+ @@extra_columns = val
93
+ end
94
+
95
+ def self.extra_columns
96
+ @@extra_columns
97
+ end
98
+
99
+ def extra_columns
100
+ self.class.extra_columns
101
+ end
81
102
  end
82
103
  end
@@ -29,6 +29,7 @@ class Ufo::Stack
29
29
  include Ufo::Util
30
30
 
31
31
  attr_reader :events
32
+ attr_writer :hide_time_took
32
33
  def initialize(stack_name)
33
34
  @stack_name = stack_name
34
35
  reset
@@ -64,6 +65,7 @@ class Ufo::Stack
64
65
  puts "Stack success status: #{last_event_status}".colorize(:green)
65
66
  end
66
67
 
68
+ return unless @hide_time_took
67
69
  took = Time.now - start_time
68
70
  puts "Time took for stack deployment: #{pretty_time(took).green}."
69
71
  end
@@ -0,0 +1,56 @@
1
+ module Ufo
2
+ class Status < Base
3
+ # used for the ufo status command
4
+ def run
5
+ unless stack_exists?(@stack_name)
6
+ puts "The stack #{@stack_name.colorize(:green)} does not exist."
7
+ return
8
+ end
9
+
10
+ resp = cloudformation.describe_stacks(stack_name: @stack_name)
11
+ stack = resp.stacks.first
12
+
13
+ puts "The current status for the stack #{@stack_name.colorize(:green)} is #{stack.stack_status.colorize(:green)}"
14
+
15
+ status_poller = Stack::Status.new(@stack_name)
16
+
17
+ if stack.stack_status =~ /_IN_PROGRESS$/
18
+ puts "Stack events (tailing):"
19
+ # tail all events until done
20
+ status_poller.hide_time_took = true
21
+ status_poller.wait
22
+ else
23
+ puts "Stack events:"
24
+ # show the last events that was user initiated
25
+ status_poller.refresh_events
26
+ status_poller.show_events(true)
27
+ end
28
+ end
29
+
30
+ def stack_exists?(stack_name)
31
+ return true if ENV['TEST']
32
+ return false if @options[:noop]
33
+
34
+ exist = nil
35
+ begin
36
+ # When the stack does not exist an exception is raised. Example:
37
+ # Aws::CloudFormation::Errors::ValidationError: Stack with id blah does not exist
38
+ resp = cloudformation.describe_stacks(stack_name: stack_name)
39
+ exist = true
40
+ rescue Aws::CloudFormation::Errors::ValidationError => e
41
+ if e.message =~ /does not exist/
42
+ exist = false
43
+ elsif e.message.include?("'stackName' failed to satisfy constraint")
44
+ # Example of e.message when describe_stack with invalid stack name
45
+ # "1 validation error detected: Value 'instance_and_route53' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*"
46
+ puts "Invalid stack name: #{stack_name}"
47
+ puts "Full error message: #{e.message}"
48
+ exit 1
49
+ else
50
+ raise # re-raise exception because unsure what other errors can happen
51
+ end
52
+ end
53
+ exist
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "4.0.3"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Ufo::VERSION
8
8
  spec.authors = ["Tung Nguyen"]
9
9
  spec.email = ["tongueroo@gmail.com"]
10
- spec.summary = "Build Docker Containers and Ship Them to AWS ECS"
10
+ spec.summary = "AWS ECS Deployment Tool"
11
11
  spec.homepage = "http://ufoships.com"
12
12
  spec.license = "MIT"
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-07 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudformation
@@ -293,6 +293,7 @@ files:
293
293
  - docs/_docs/automated-cleanup.md
294
294
  - docs/_docs/conventions.md
295
295
  - docs/_docs/customize-cloudformation.md
296
+ - docs/_docs/ecs-network-mode.md
296
297
  - docs/_docs/faq.md
297
298
  - docs/_docs/fargate.md
298
299
  - docs/_docs/helpers.md
@@ -527,6 +528,7 @@ files:
527
528
  - lib/ufo/stack/context.rb
528
529
  - lib/ufo/stack/helper.rb
529
530
  - lib/ufo/stack/status.rb
531
+ - lib/ufo/status.rb
530
532
  - lib/ufo/stop.rb
531
533
  - lib/ufo/task.rb
532
534
  - lib/ufo/tasks.rb
@@ -590,7 +592,7 @@ rubyforge_project:
590
592
  rubygems_version: 2.7.6
591
593
  signing_key:
592
594
  specification_version: 4
593
- summary: Build Docker Containers and Ship Them to AWS ECS
595
+ summary: AWS ECS Deployment Tool
594
596
  test_files:
595
597
  - spec/fixtures/apps/describe_services.json
596
598
  - spec/fixtures/cfn/stack-events-complete.json